Skip to content

Commit

Permalink
chore: Standardized test setup (create-options)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijlee2 committed Feb 10, 2023
1 parent 9f0f2b4 commit 2ccb45e
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 109 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/customizations.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > customizations', function () {
const codemodOptions = {
addonLocation: 'packages/new-v1-addon',
projectRoot: 'tmp/new-v1-addon-customizations',
testAppLocation: 'demo-app',
testAppName: 'demo-app-for-new-v1-addon',
};

const inputProject = {
'package.json': JSON.stringify(
{
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
dependencies: {
'ember-cli-babel': '^7.26.11',
'ember-cli-htmlbars': '^6.1.1',
Expand All @@ -33,7 +27,7 @@ test('migration | ember-addon | steps | create-options > customizations', functi

assert.deepEqual(createOptions(codemodOptions), {
locations: {
addon: 'packages/new-v1-addon',
addon: 'packages/ember-container-query',
testApp: 'demo-app',
},
packageManager: {
Expand All @@ -50,13 +44,13 @@ test('migration | ember-addon | steps | create-options > customizations', functi
hasGlint: false,
hasTypeScript: false,
isV1Addon: true,
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
},
testApp: {
name: 'demo-app-for-new-v1-addon',
name: 'demo-app-for-ember-container-query',
},
},
projectRoot: 'tmp/new-v1-addon-customizations',
projectRoot: 'tmp/ember-container-query-customizations',
});
});
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/javascript.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > error handling (package.json is an empty file)', function () {
const options = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': '',
'yarn.lock': '',
};

loadFixture(inputProject, options);
loadFixture(inputProject, codemodOptions);

assert.throws(
() => {
createOptions(options);
createOptions(codemodOptions);
},
(error) => {
assert.strictEqual(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/javascript.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > error handling (package.json is not a valid JSON)', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': '{\n "name": }',
'yarn.lock': '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/javascript.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > error handling (package name is missing)', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': '{}',
'yarn.lock': '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/scoped.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > error handling (package name is not valid)', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': JSON.stringify(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/javascript.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > error handling (package version is missing)', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': JSON.stringify(
{
name: 'new-v1-addon',
name: 'ember-container-query',
},
null,
2
Expand Down
20 changes: 7 additions & 13 deletions tests/migration/ember-addon/steps/create-options/glint.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/glint.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > glint', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-typescript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': JSON.stringify(
{
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
dependencies: {
'ember-cli-babel': '^7.26.11',
'ember-cli-htmlbars': '^6.1.1',
Expand All @@ -36,7 +30,7 @@ test('migration | ember-addon | steps | create-options > glint', function () {

assert.deepEqual(createOptions(codemodOptions), {
locations: {
addon: 'new-v1-addon',
addon: 'ember-container-query',
testApp: 'test-app',
},
packageManager: {
Expand All @@ -55,13 +49,13 @@ test('migration | ember-addon | steps | create-options > glint', function () {
hasGlint: true,
hasTypeScript: true,
isV1Addon: true,
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
},
testApp: {
name: 'test-app',
},
},
projectRoot: 'tmp/new-v1-addon-typescript',
projectRoot: 'tmp/ember-container-query-glint',
});
});
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/javascript.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > javascript', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': JSON.stringify(
{
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
dependencies: {
'ember-cli-babel': '^7.26.11',
'ember-cli-htmlbars': '^6.1.1',
Expand All @@ -33,7 +27,7 @@ test('migration | ember-addon | steps | create-options > javascript', function (

assert.deepEqual(createOptions(codemodOptions), {
locations: {
addon: 'new-v1-addon',
addon: 'ember-container-query',
testApp: 'test-app',
},
packageManager: {
Expand All @@ -50,13 +44,13 @@ test('migration | ember-addon | steps | create-options > javascript', function (
hasGlint: false,
hasTypeScript: false,
isV1Addon: true,
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
},
testApp: {
name: 'test-app',
},
},
projectRoot: 'tmp/new-v1-addon-javascript',
projectRoot: 'tmp/ember-container-query-javascript',
});
});
4 changes: 2 additions & 2 deletions tests/migration/ember-addon/steps/create-options/npm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assert, loadFixture, test } from '../../../../helpers/testing.js';
test('migration | ember-addon | steps | create-options > npm', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
projectRoot: 'tmp/new-v1-addon-npm',
testAppLocation: undefined,
testAppName: undefined,
};
Expand Down Expand Up @@ -57,6 +57,6 @@ test('migration | ember-addon | steps | create-options > npm', function () {
name: 'test-app',
},
},
projectRoot: 'tmp/new-v1-addon-javascript',
projectRoot: 'tmp/new-v1-addon-npm',
});
});
4 changes: 2 additions & 2 deletions tests/migration/ember-addon/steps/create-options/pnpm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assert, loadFixture, test } from '../../../../helpers/testing.js';
test('migration | ember-addon | steps | create-options > pnpm', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
projectRoot: 'tmp/new-v1-addon-pnpm',
testAppLocation: undefined,
testAppName: undefined,
};
Expand Down Expand Up @@ -57,6 +57,6 @@ test('migration | ember-addon | steps | create-options > pnpm', function () {
name: 'test-app',
},
},
projectRoot: 'tmp/new-v1-addon-javascript',
projectRoot: 'tmp/new-v1-addon-pnpm',
});
});
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/typescript.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > typescript', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-typescript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': JSON.stringify(
{
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
dependencies: {
'ember-cli-babel': '^7.26.11',
'ember-cli-htmlbars': '^6.1.1',
Expand All @@ -35,7 +29,7 @@ test('migration | ember-addon | steps | create-options > typescript', function (

assert.deepEqual(createOptions(codemodOptions), {
locations: {
addon: 'new-v1-addon',
addon: 'ember-container-query',
testApp: 'test-app',
},
packageManager: {
Expand All @@ -53,13 +47,13 @@ test('migration | ember-addon | steps | create-options > typescript', function (
hasGlint: false,
hasTypeScript: true,
isV1Addon: true,
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
},
testApp: {
name: 'test-app',
},
},
projectRoot: 'tmp/new-v1-addon-typescript',
projectRoot: 'tmp/ember-container-query-typescript',
});
});
22 changes: 8 additions & 14 deletions tests/migration/ember-addon/steps/create-options/v2-addon.test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import { createOptions } from '../../../../../src/migration/ember-addon/steps/index.js';
import { codemodOptions } from '../../../../helpers/shared-test-setups/javascript.js';
import { assert, loadFixture, test } from '../../../../helpers/testing.js';

test('migration | ember-addon | steps | create-options > v2 addon', function () {
const codemodOptions = {
addonLocation: undefined,
projectRoot: 'tmp/new-v1-addon-javascript',
testAppLocation: undefined,
testAppName: undefined,
};

const inputProject = {
'package.json': JSON.stringify(
{
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
private: true,
workspaces: ['new-v1-addon', 'test-app'],
workspaces: ['ember-container-query', 'test-app'],
},
null,
2
Expand All @@ -27,7 +21,7 @@ test('migration | ember-addon | steps | create-options > v2 addon', function ()

assert.deepEqual(createOptions(codemodOptions), {
locations: {
addon: 'new-v1-addon',
addon: 'ember-container-query',
testApp: 'test-app',
},
packageManager: {
Expand All @@ -41,13 +35,13 @@ test('migration | ember-addon | steps | create-options > v2 addon', function ()
hasGlint: false,
hasTypeScript: false,
isV1Addon: false,
name: 'new-v1-addon',
version: '0.0.0',
name: 'ember-container-query',
version: '3.2.0',
},
testApp: {
name: 'test-app',
},
},
projectRoot: 'tmp/new-v1-addon-javascript',
projectRoot: 'tmp/ember-container-query-javascript',
});
});

0 comments on commit 2ccb45e

Please sign in to comment.