From 62a97d5482f05a8ddc8d16da7e084a70ef4170d9 Mon Sep 17 00:00:00 2001 From: Bert De Block Date: Sat, 11 Jun 2022 11:12:03 +0200 Subject: [PATCH] [BUGFIX release] Fix generated import paths for test setup functions in addons --- .../tests/acceptance/__name__-test.js | 2 +- .../tests/acceptance/__name__-test.js | 2 +- .../__testType__/__path__/__test__.js | 4 +- .../__testType__/__path__/__test__.js | 4 +- .../__testType__/__path__/__test__.js | 2 +- .../__testType__/__path__/__test__.js | 2 +- .../__collection__/__name__-test.js | 2 +- .../__collection__/__name__-test.js | 2 +- .../__testType__/__path__/__test__.js | 2 +- .../__testType__/__path__/__test__.js | 2 +- .../__testType__/__path__/__test__.js | 2 +- .../__testType__/__path__/__test__.js | 2 +- blueprints/-utils.js | 9 ++ blueprints/acceptance-test/index.js | 4 +- .../tests/acceptance/__name__-test.ts | 2 +- .../tests/acceptance/__name__-test.ts | 2 +- blueprints/component-test/index.js | 2 + .../__testType__/__path__/__test__.ts | 4 +- .../__testType__/__path__/__test__.ts | 4 +- blueprints/controller-test/index.js | 2 + .../__testType__/__path__/__test__.ts | 2 +- .../__testType__/__path__/__test__.ts | 2 +- blueprints/helper-test/index.js | 5 +- .../__collection__/__name__-test.ts | 2 +- .../__collection__/__name__-test.ts | 2 +- blueprints/route-test/index.js | 2 + .../__testType__/__path__/__test__.ts | 2 +- .../__testType__/__path__/__test__.ts | 2 +- blueprints/service-test/index.js | 2 + .../__testType__/__path__/__test__.ts | 2 +- .../__testType__/__path__/__test__.ts | 2 +- node-tests/blueprints/acceptance-test-test.js | 18 ++++ node-tests/blueprints/component-test-test.js | 99 ++++++++++++++----- node-tests/blueprints/controller-test-test.js | 67 +++++++++---- node-tests/blueprints/helper-test-test.js | 44 +++++++-- node-tests/blueprints/route-test-test.js | 53 +++++++--- node-tests/blueprints/service-test-test.js | 28 ++++++ .../acceptance-test/mocha-rfc268-addon.js | 13 +++ .../acceptance-test/qunit-rfc268-addon.js | 2 +- .../component-test/mocha-rfc232-addon.js | 27 +++++ .../component-test/mocha-rfc232-unit-addon.js | 12 +++ .../fixtures/component-test/rfc232-addon.js | 26 +++++ .../component-test/rfc232-unit-addon.js | 11 +++ .../controller-test/mocha-rfc232-addon.js | 13 +++ .../fixtures/controller-test/rfc232-addon.js | 12 +++ .../helper-test/mocha-rfc232-addon.js | 18 ++++ .../fixtures/helper-test/rfc232-addon.js | 17 ++++ .../fixtures/route-test/mocha-rfc232-addon.js | 12 +++ .../fixtures/route-test/rfc232-addon.js | 11 +++ .../service-test/mocha-rfc232-addon.js | 13 +++ .../fixtures/service-test/rfc232-addon.js | 12 +++ 51 files changed, 496 insertions(+), 94 deletions(-) create mode 100644 blueprints/-utils.js create mode 100644 node-tests/fixtures/acceptance-test/mocha-rfc268-addon.js create mode 100644 node-tests/fixtures/component-test/mocha-rfc232-addon.js create mode 100644 node-tests/fixtures/component-test/mocha-rfc232-unit-addon.js create mode 100644 node-tests/fixtures/component-test/rfc232-addon.js create mode 100644 node-tests/fixtures/component-test/rfc232-unit-addon.js create mode 100644 node-tests/fixtures/controller-test/mocha-rfc232-addon.js create mode 100644 node-tests/fixtures/controller-test/rfc232-addon.js create mode 100644 node-tests/fixtures/helper-test/mocha-rfc232-addon.js create mode 100644 node-tests/fixtures/helper-test/rfc232-addon.js create mode 100644 node-tests/fixtures/route-test/mocha-rfc232-addon.js create mode 100644 node-tests/fixtures/route-test/rfc232-addon.js create mode 100644 node-tests/fixtures/service-test/mocha-rfc232-addon.js create mode 100644 node-tests/fixtures/service-test/rfc232-addon.js diff --git a/blueprints-js/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js b/blueprints-js/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js index c829c1213b4..9f28e50b894 100644 --- a/blueprints-js/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js +++ b/blueprints-js/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js @@ -1,6 +1,6 @@ import { describe, it } from 'mocha'; import { expect } from 'chai'; -import { setupApplicationTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupApplicationTest } from '<%= modulePrefix %>/tests/helpers'; import { visit, currentURL } from '@ember/test-helpers'; describe('<%= friendlyTestName %>', function () { diff --git a/blueprints-js/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js b/blueprints-js/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js index 874340678ec..07ae1fa1048 100644 --- a/blueprints-js/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +++ b/blueprints-js/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; import { visit, currentURL } from '@ember/test-helpers'; -import { setupApplicationTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupApplicationTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestName %>', function (hooks) { setupApplicationTest(hooks); diff --git a/blueprints-js/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints-js/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js index 1124f53ec61..09e004001b3 100644 --- a/blueprints-js/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +++ b/blueprints-js/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -1,6 +1,6 @@ <% if (testType === 'integration') { %>import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupRenderingTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; import { render } from '@ember/test-helpers'; <%= hbsImportStatement %> @@ -26,7 +26,7 @@ describe('<%= friendlyTestDescription %>', function () { }); });<% } else if (testType === 'unit') { %>import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function () { setupTest(); diff --git a/blueprints-js/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints-js/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js index 922cc75b599..0140ea71ae8 100644 --- a/blueprints-js/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +++ b/blueprints-js/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -1,5 +1,5 @@ <% if (testType === 'integration') { %>import { module, test } from 'qunit'; -import { setupRenderingTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; import { render } from '@ember/test-helpers'; <%= hbsImportStatement %> @@ -24,7 +24,7 @@ module('<%= friendlyTestDescription %>', function (hooks) { assert.dom(this.element).hasText('template block text'); }); });<% } else if (testType === 'unit') { %>import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function (hooks) { setupTest(hooks); diff --git a/blueprints-js/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints-js/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js index 70beddc7a11..8e0a4be04e8 100644 --- a/blueprints-js/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +++ b/blueprints-js/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function () { setupTest(); diff --git a/blueprints-js/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints-js/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js index 576450eeeb7..211e4cf497d 100644 --- a/blueprints-js/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +++ b/blueprints-js/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function (hooks) { setupTest(hooks); diff --git a/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js b/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js index caf6e271319..1d317244677 100644 --- a/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +++ b/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupRenderingTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; import { render } from '@ember/test-helpers'; <%= hbsImportStatement %> diff --git a/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js b/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js index 5197aa67b56..a04bbbf5077 100644 --- a/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +++ b/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupRenderingTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; import { render } from '@ember/test-helpers'; <%= hbsImportStatement %> diff --git a/blueprints-js/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints-js/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js index 163dbd6210b..8a55ca6c2f0 100644 --- a/blueprints-js/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +++ b/blueprints-js/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function () { setupTest(); diff --git a/blueprints-js/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints-js/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js index 1bbe98f8213..942fd41cc9c 100644 --- a/blueprints-js/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +++ b/blueprints-js/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function (hooks) { setupTest(hooks); diff --git a/blueprints-js/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints-js/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js index 3c8a84d0323..2124d8d45fa 100644 --- a/blueprints-js/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +++ b/blueprints-js/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function () { setupTest(); diff --git a/blueprints-js/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints-js/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js index fc13a97e339..14ec42e38ad 100644 --- a/blueprints-js/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +++ b/blueprints-js/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function (hooks) { setupTest(hooks); diff --git a/blueprints/-utils.js b/blueprints/-utils.js new file mode 100644 index 00000000000..37f7754f770 --- /dev/null +++ b/blueprints/-utils.js @@ -0,0 +1,9 @@ +const { dasherize } = require('ember-cli-string-utils'); + +function modulePrefixForProject(project) { + return dasherize(project.config().modulePrefix); +} + +module.exports = { + modulePrefixForProject, +}; diff --git a/blueprints/acceptance-test/index.js b/blueprints/acceptance-test/index.js index 547f085df20..0f70417307e 100644 --- a/blueprints/acceptance-test/index.js +++ b/blueprints/acceptance-test/index.js @@ -6,6 +6,7 @@ const pathUtil = require('ember-cli-path-utils'); const stringUtils = require('ember-cli-string-utils'); const maybePolyfillTypeScriptBlueprints = require('../-maybe-polyfill-typescript-blueprints'); +const { modulePrefixForProject } = require('../-utils'); const useTestFrameworkDetector = require('../test-framework-detector'); module.exports = useTestFrameworkDetector({ @@ -35,7 +36,8 @@ module.exports = useTestFrameworkDetector({ ].join(' | '); return { - testFolderRoot: testFolderRoot, + modulePrefix: modulePrefixForProject(options.project), + testFolderRoot, friendlyTestName, destroyAppExists, }; diff --git a/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.ts b/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.ts index c829c1213b4..9f28e50b894 100644 --- a/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.ts +++ b/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.ts @@ -1,6 +1,6 @@ import { describe, it } from 'mocha'; import { expect } from 'chai'; -import { setupApplicationTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupApplicationTest } from '<%= modulePrefix %>/tests/helpers'; import { visit, currentURL } from '@ember/test-helpers'; describe('<%= friendlyTestName %>', function () { diff --git a/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.ts b/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.ts index 874340678ec..07ae1fa1048 100644 --- a/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.ts +++ b/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.ts @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; import { visit, currentURL } from '@ember/test-helpers'; -import { setupApplicationTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupApplicationTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestName %>', function (hooks) { setupApplicationTest(hooks); diff --git a/blueprints/component-test/index.js b/blueprints/component-test/index.js index 9f6c3547cc8..1e89db6e6b0 100644 --- a/blueprints/component-test/index.js +++ b/blueprints/component-test/index.js @@ -7,6 +7,7 @@ const getPathOption = require('ember-cli-get-component-path-option'); const semver = require('semver'); const maybePolyfillTypeScriptBlueprints = require('../-maybe-polyfill-typescript-blueprints'); +const { modulePrefixForProject } = require('../-utils'); const useTestFrameworkDetector = require('../test-framework-detector'); function invocationFor(options) { @@ -81,6 +82,7 @@ module.exports = useTestFrameworkDetector({ let selfCloseComponent = (descriptor) => `<${descriptor} />`; return { + modulePrefix: modulePrefixForProject(options.project), path: getPathOption(options), testType: testType, componentName, diff --git a/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts b/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts index 1124f53ec61..09e004001b3 100644 --- a/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts +++ b/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts @@ -1,6 +1,6 @@ <% if (testType === 'integration') { %>import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupRenderingTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; import { render } from '@ember/test-helpers'; <%= hbsImportStatement %> @@ -26,7 +26,7 @@ describe('<%= friendlyTestDescription %>', function () { }); });<% } else if (testType === 'unit') { %>import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function () { setupTest(); diff --git a/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts b/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts index 00936ce1c73..d2d4e87d1a4 100644 --- a/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts +++ b/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts @@ -1,5 +1,5 @@ <% if (testType === 'integration') { %>import { module, test } from 'qunit'; -import { setupRenderingTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; import { render } from '@ember/test-helpers'; <%= hbsImportStatement %> @@ -24,7 +24,7 @@ module('<%= friendlyTestDescription %>', function (hooks) { assert.dom(this.element).hasText('template block text'); }); });<% } else if (testType === 'unit') { %>import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function (hooks) { setupTest(hooks); diff --git a/blueprints/controller-test/index.js b/blueprints/controller-test/index.js index f5d2defe4a4..3d2b1f29f9f 100644 --- a/blueprints/controller-test/index.js +++ b/blueprints/controller-test/index.js @@ -6,6 +6,7 @@ const useTestFrameworkDetector = require('../test-framework-detector'); const path = require('path'); const maybePolyfillTypeScriptBlueprints = require('../-maybe-polyfill-typescript-blueprints'); +const { modulePrefixForProject } = require('../-utils'); module.exports = useTestFrameworkDetector({ description: 'Generates a controller unit test.', @@ -22,6 +23,7 @@ module.exports = useTestFrameworkDetector({ let controllerPathName = dasherizedModuleName; return { + modulePrefix: modulePrefixForProject(options.project), controllerPathName: controllerPathName, friendlyTestDescription: ['Unit', 'Controller', dasherizedModuleName].join(' | '), }; diff --git a/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts b/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts index 70beddc7a11..8e0a4be04e8 100644 --- a/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts +++ b/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function () { setupTest(); diff --git a/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts b/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts index 576450eeeb7..211e4cf497d 100644 --- a/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts +++ b/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function (hooks) { setupTest(hooks); diff --git a/blueprints/helper-test/index.js b/blueprints/helper-test/index.js index 4a54bd252e1..f8e89935a57 100644 --- a/blueprints/helper-test/index.js +++ b/blueprints/helper-test/index.js @@ -1,10 +1,10 @@ 'use strict'; -const stringUtils = require('ember-cli-string-utils'); const isPackageMissing = require('ember-cli-is-package-missing'); const semver = require('semver'); const maybePolyfillTypeScriptBlueprints = require('../-maybe-polyfill-typescript-blueprints'); +const { modulePrefixForProject } = require('../-utils'); const useTestFrameworkDetector = require('../test-framework-detector'); @@ -34,15 +34,14 @@ module.exports = useTestFrameworkDetector({ locals: function (options) { let friendlyTestName = ['Integration', 'Helper', options.entity.name].join(' | '); - let dasherizedModulePrefix = stringUtils.dasherize(options.project.config().modulePrefix); let hbsImportStatement = this._useNamedHbsImport() ? "import { hbs } from 'ember-cli-htmlbars';" : "import hbs from 'htmlbars-inline-precompile';"; return { + modulePrefix: modulePrefixForProject(options.project), friendlyTestName, - dasherizedModulePrefix, hbsImportStatement, }; }, diff --git a/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.ts b/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.ts index caf6e271319..1d317244677 100644 --- a/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.ts +++ b/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupRenderingTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; import { render } from '@ember/test-helpers'; <%= hbsImportStatement %> diff --git a/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.ts b/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.ts index 5197aa67b56..a04bbbf5077 100644 --- a/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.ts +++ b/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.ts @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupRenderingTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; import { render } from '@ember/test-helpers'; <%= hbsImportStatement %> diff --git a/blueprints/route-test/index.js b/blueprints/route-test/index.js index fc79e51b099..e546a8b13c3 100644 --- a/blueprints/route-test/index.js +++ b/blueprints/route-test/index.js @@ -5,6 +5,7 @@ const stringUtil = require('ember-cli-string-utils'); const useTestFrameworkDetector = require('../test-framework-detector'); const maybePolyfillTypeScriptBlueprints = require('../-maybe-polyfill-typescript-blueprints'); +const { modulePrefixForProject } = require('../-utils'); module.exports = useTestFrameworkDetector({ description: 'Generates a route unit test.', @@ -57,6 +58,7 @@ module.exports = useTestFrameworkDetector({ } return { + modulePrefix: modulePrefixForProject(options.project), friendlyTestDescription: ['Unit', 'Route', options.entity.name].join(' | '), moduleName: stringUtil.dasherize(moduleName), }; diff --git a/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts b/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts index 163dbd6210b..8a55ca6c2f0 100644 --- a/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts +++ b/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function () { setupTest(); diff --git a/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts b/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts index 1bbe98f8213..942fd41cc9c 100644 --- a/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts +++ b/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function (hooks) { setupTest(hooks); diff --git a/blueprints/service-test/index.js b/blueprints/service-test/index.js index 308126e7a67..0dd10e1f9b0 100644 --- a/blueprints/service-test/index.js +++ b/blueprints/service-test/index.js @@ -1,6 +1,7 @@ 'use strict'; const maybePolyfillTypeScriptBlueprints = require('../-maybe-polyfill-typescript-blueprints'); +const { modulePrefixForProject } = require('../-utils'); const useTestFrameworkDetector = require('../test-framework-detector'); module.exports = useTestFrameworkDetector({ @@ -26,6 +27,7 @@ module.exports = useTestFrameworkDetector({ locals(options) { return { + modulePrefix: modulePrefixForProject(options.project), friendlyTestDescription: ['Unit', 'Service', options.entity.name].join(' | '), }; }, diff --git a/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts b/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts index 3c8a84d0323..2124d8d45fa 100644 --- a/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts +++ b/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function () { setupTest(); diff --git a/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts b/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts index fc13a97e339..14ec42e38ad 100644 --- a/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts +++ b/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.ts @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function (hooks) { setupTest(hooks); diff --git a/node-tests/blueprints/acceptance-test-test.js b/node-tests/blueprints/acceptance-test-test.js index 5a7a1c4f577..2ef48c1948f 100644 --- a/node-tests/blueprints/acceptance-test-test.js +++ b/node-tests/blueprints/acceptance-test-test.js @@ -144,5 +144,23 @@ describe('Blueprint: acceptance-test', function () { }); }); }); + + describe('with ember-mocha@0.16.2', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('acceptance-test foo', function () { + return emberGenerateDestroy(['acceptance-test', 'foo'], (_file) => { + expect(_file('tests/acceptance/foo-test.js')).to.equal( + fixture('acceptance-test/mocha-rfc268-addon.js') + ); + }); + }); + }); }); }); diff --git a/node-tests/blueprints/component-test-test.js b/node-tests/blueprints/component-test-test.js index d921f4f6658..ea29b87d637 100644 --- a/node-tests/blueprints/component-test-test.js +++ b/node-tests/blueprints/component-test-test.js @@ -193,43 +193,90 @@ describe('Blueprint: component-test', function () { describe('in addon', function () { beforeEach(function () { - return emberNew({ target: 'addon' }) - .then(() => - modifyPackages([ - { name: 'ember-qunit', delete: true }, - { name: 'ember-cli-qunit', dev: true }, - ]) - ) - .then(() => generateFakePackageManifest('ember-cli-qunit', '4.1.0')); + return emberNew({ target: 'addon' }); }); - it('component-test x-foo', function () { - return emberGenerateDestroy(['component-test', 'x-foo'], (_file) => { - expect(_file('tests/integration/components/x-foo-test.js')).to.equal( - fixture('component-test/default.js') - ); + describe('with ember-cli-qunit@4.1.0', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-cli-qunit', dev: true }, + ]); + generateFakePackageManifest('ember-cli-qunit', '4.1.0'); + }); + + it('component-test x-foo', function () { + return emberGenerateDestroy(['component-test', 'x-foo'], (_file) => { + expect(_file('tests/integration/components/x-foo-test.js')).to.equal( + fixture('component-test/default.js') + ); - expect(_file('app/component-test/x-foo.js')).to.not.exist; + expect(_file('app/component-test/x-foo.js')).to.not.exist; + }); + }); + + it('component-test x-foo --unit', function () { + return emberGenerateDestroy(['component-test', 'x-foo', '--unit'], (_file) => { + expect(_file('tests/unit/components/x-foo-test.js')).to.equal( + fixture('component-test/unit.js') + ); + + expect(_file('app/component-test/x-foo.js')).to.not.exist; + }); + }); + + it('component-test x-foo --dummy', function () { + return emberGenerateDestroy(['component-test', 'x-foo', '--dummy'], (_file) => { + expect(_file('tests/integration/components/x-foo-test.js')).to.equal( + fixture('component-test/default.js') + ); + + expect(_file('app/component-test/x-foo.js')).to.not.exist; + }); }); }); - it('component-test x-foo --unit', function () { - return emberGenerateDestroy(['component-test', 'x-foo', '--unit'], (_file) => { - expect(_file('tests/unit/components/x-foo-test.js')).to.equal( - fixture('component-test/unit.js') - ); + describe('with ember-qunit (default)', function () { + it('component-test foo', function () { + return emberGenerateDestroy(['component-test', 'foo'], (_file) => { + expect(_file('tests/integration/components/foo-test.js')).to.equal( + fixture('component-test/rfc232-addon.js') + ); + }); + }); - expect(_file('app/component-test/x-foo.js')).to.not.exist; + it('component-test foo --unit', function () { + return emberGenerateDestroy(['component-test', 'foo', '--unit'], (_file) => { + expect(_file('tests/unit/components/foo-test.js')).to.equal( + fixture('component-test/rfc232-unit-addon.js') + ); + }); }); }); - it('component-test x-foo --dummy', function () { - return emberGenerateDestroy(['component-test', 'x-foo', '--dummy'], (_file) => { - expect(_file('tests/integration/components/x-foo-test.js')).to.equal( - fixture('component-test/default.js') - ); + describe('with ember-mocha@0.16.2', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); - expect(_file('app/component-test/x-foo.js')).to.not.exist; + it('component-test foo', function () { + return emberGenerateDestroy(['component-test', 'foo'], (_file) => { + expect(_file('tests/integration/components/foo-test.js')).to.equal( + fixture('component-test/mocha-rfc232-addon.js') + ); + }); + }); + + it('component-test foo --unit', function () { + return emberGenerateDestroy(['component-test', 'foo', '--unit'], (_file) => { + expect(_file('tests/unit/components/foo-test.js')).to.equal( + fixture('component-test/mocha-rfc232-unit-addon.js') + ); + }); }); }); }); diff --git a/node-tests/blueprints/controller-test-test.js b/node-tests/blueprints/controller-test-test.js index a7569690a18..4d301cae653 100644 --- a/node-tests/blueprints/controller-test-test.js +++ b/node-tests/blueprints/controller-test-test.js @@ -153,29 +153,60 @@ describe('Blueprint: controller-test', function () { describe('in addon', function () { beforeEach(function () { - return emberNew({ target: 'addon' }) - .then(() => - modifyPackages([ - { name: 'ember-qunit', delete: true }, - { name: 'ember-cli-qunit', dev: true }, - ]) - ) - .then(() => generateFakePackageManifest('ember-cli-qunit', '4.1.0')); + return emberNew({ target: 'addon' }); }); - it('controller-test foo', function () { - return emberGenerateDestroy(['controller-test', 'foo'], (_file) => { - expect(_file('tests/unit/controllers/foo-test.js')).to.equal( - fixture('controller-test/default.js') - ); + describe('with ember-cli-qunit@4.1.0', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-cli-qunit', dev: true }, + ]); + generateFakePackageManifest('ember-cli-qunit', '4.1.0'); + }); + + it('controller-test foo', function () { + return emberGenerateDestroy(['controller-test', 'foo'], (_file) => { + expect(_file('tests/unit/controllers/foo-test.js')).to.equal( + fixture('controller-test/default.js') + ); + }); + }); + + it('controller-test foo/bar', function () { + return emberGenerateDestroy(['controller-test', 'foo/bar'], (_file) => { + expect(_file('tests/unit/controllers/foo/bar-test.js')).to.equal( + fixture('controller-test/default-nested.js') + ); + }); }); }); - it('controller-test foo/bar', function () { - return emberGenerateDestroy(['controller-test', 'foo/bar'], (_file) => { - expect(_file('tests/unit/controllers/foo/bar-test.js')).to.equal( - fixture('controller-test/default-nested.js') - ); + describe('with ember-qunit (default)', function () { + it('controller-test foo', function () { + return emberGenerateDestroy(['controller-test', 'foo'], (_file) => { + expect(_file('tests/unit/controllers/foo-test.js')).to.equal( + fixture('controller-test/rfc232-addon.js') + ); + }); + }); + }); + + describe('with ember-mocha@0.16.2', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('controller-test foo', function () { + return emberGenerateDestroy(['controller-test', 'foo'], (_file) => { + expect(_file('tests/unit/controllers/foo-test.js')).to.equal( + fixture('controller-test/mocha-rfc232-addon.js') + ); + }); }); }); }); diff --git a/node-tests/blueprints/helper-test-test.js b/node-tests/blueprints/helper-test-test.js index 2d9004dd9c5..8edbdc5decb 100644 --- a/node-tests/blueprints/helper-test-test.js +++ b/node-tests/blueprints/helper-test-test.js @@ -121,20 +121,52 @@ describe('Blueprint: helper-test', function () { describe('in addon', function () { beforeEach(function () { - return emberNew({ target: 'addon' }).then(() => { + return emberNew({ target: 'addon' }); + }); + + describe('with ember-cli-qunit@4.1.0', function () { + beforeEach(function () { modifyPackages([ { name: 'ember-qunit', delete: true }, { name: 'ember-cli-qunit', dev: true }, ]); generateFakePackageManifest('ember-cli-qunit', '4.1.0'); }); + + it('helper-test foo/bar-baz', function () { + return emberGenerateDestroy(['helper-test', 'foo/bar-baz'], (_file) => { + expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( + fixture('helper-test/integration.js') + ); + }); + }); + }); + + describe('with ember-qunit (default)', function () { + it('helper-test foo', function () { + return emberGenerateDestroy(['helper-test', 'foo'], (_file) => { + expect(_file('tests/integration/helpers/foo-test.js')).to.equal( + fixture('helper-test/rfc232-addon.js') + ); + }); + }); }); - it('helper-test foo/bar-baz', function () { - return emberGenerateDestroy(['helper-test', 'foo/bar-baz'], (_file) => { - expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal( - fixture('helper-test/integration.js') - ); + describe('with ember-mocha@0.16.2', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('helper-test foo', function () { + return emberGenerateDestroy(['helper-test', 'foo'], (_file) => { + expect(_file('tests/integration/helpers/foo-test.js')).to.equal( + fixture('helper-test/mocha-rfc232-addon.js') + ); + }); }); }); }); diff --git a/node-tests/blueprints/route-test-test.js b/node-tests/blueprints/route-test-test.js index 5d4da686287..ef8eade5e72 100644 --- a/node-tests/blueprints/route-test-test.js +++ b/node-tests/blueprints/route-test-test.js @@ -107,19 +107,50 @@ describe('Blueprint: route-test', function () { describe('in addon', function () { beforeEach(function () { - return emberNew({ target: 'addon' }) - .then(() => - modifyPackages([ - { name: 'ember-qunit', delete: true }, - { name: 'ember-cli-qunit', dev: true }, - ]) - ) - .then(() => generateFakePackageManifest('ember-cli-qunit', '4.1.0')); + return emberNew({ target: 'addon' }); }); - it('route-test foo', function () { - return emberGenerateDestroy(['route-test', 'foo'], (_file) => { - expect(_file('tests/unit/routes/foo-test.js')).to.equal(fixture('route-test/default.js')); + describe('with ember-cli-qunit@4.1.0', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-cli-qunit', dev: true }, + ]); + generateFakePackageManifest('ember-cli-qunit', '4.1.0'); + }); + + it('route-test foo', function () { + return emberGenerateDestroy(['route-test', 'foo'], (_file) => { + expect(_file('tests/unit/routes/foo-test.js')).to.equal(fixture('route-test/default.js')); + }); + }); + }); + + describe('with ember-qunit (default)', function () { + it('route-test foo', function () { + return emberGenerateDestroy(['route-test', 'foo'], (_file) => { + expect(_file('tests/unit/routes/foo-test.js')).to.equal( + fixture('route-test/rfc232-addon.js') + ); + }); + }); + }); + + describe('with ember-mocha@0.16.2', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('route-test foo', function () { + return emberGenerateDestroy(['route-test', 'foo'], (_file) => { + expect(_file('tests/unit/routes/foo-test.js')).to.equal( + fixture('route-test/mocha-rfc232-addon.js') + ); + }); }); }); }); diff --git a/node-tests/blueprints/service-test-test.js b/node-tests/blueprints/service-test-test.js index ff5a3c2dcdd..66dd4feac79 100644 --- a/node-tests/blueprints/service-test-test.js +++ b/node-tests/blueprints/service-test-test.js @@ -151,5 +151,33 @@ describe('Blueprint: service-test', function () { }); }); }); + + describe('with ember-qunit (default)', function () { + it('service-test foo', function () { + return emberGenerateDestroy(['service-test', 'foo'], (_file) => { + expect(_file('tests/unit/services/foo-test.js')).to.equal( + fixture('service-test/rfc232-addon.js') + ); + }); + }); + }); + + describe('with ember-mocha@0.16.2', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('service-test foo', function () { + return emberGenerateDestroy(['service-test', 'foo'], (_file) => { + expect(_file('tests/unit/services/foo-test.js')).to.equal( + fixture('service-test/mocha-rfc232-addon.js') + ); + }); + }); + }); }); }); diff --git a/node-tests/fixtures/acceptance-test/mocha-rfc268-addon.js b/node-tests/fixtures/acceptance-test/mocha-rfc268-addon.js new file mode 100644 index 00000000000..e5779451abc --- /dev/null +++ b/node-tests/fixtures/acceptance-test/mocha-rfc268-addon.js @@ -0,0 +1,13 @@ +import { describe, it } from 'mocha'; +import { expect } from 'chai'; +import { setupApplicationTest } from 'dummy/tests/helpers'; +import { visit, currentURL } from '@ember/test-helpers'; + +describe('Acceptance | foo', function () { + setupApplicationTest(); + + it('can visit /foo', async function () { + await visit('/foo'); + expect(currentURL()).to.equal('/foo'); + }); +}); diff --git a/node-tests/fixtures/acceptance-test/qunit-rfc268-addon.js b/node-tests/fixtures/acceptance-test/qunit-rfc268-addon.js index 2d001b04e05..88e63811d12 100644 --- a/node-tests/fixtures/acceptance-test/qunit-rfc268-addon.js +++ b/node-tests/fixtures/acceptance-test/qunit-rfc268-addon.js @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; import { visit, currentURL } from '@ember/test-helpers'; -import { setupApplicationTest } from 'my-addon/tests/helpers'; +import { setupApplicationTest } from 'dummy/tests/helpers'; module('Acceptance | foo', function (hooks) { setupApplicationTest(hooks); diff --git a/node-tests/fixtures/component-test/mocha-rfc232-addon.js b/node-tests/fixtures/component-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..0424b8f4429 --- /dev/null +++ b/node-tests/fixtures/component-test/mocha-rfc232-addon.js @@ -0,0 +1,27 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +describe('Integration | Component | foo', function () { + setupRenderingTest(); + + it('renders', async function () { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + expect(this.element.textContent.trim()).to.equal(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + expect(this.element.textContent.trim()).to.equal('template block text'); + }); +}); diff --git a/node-tests/fixtures/component-test/mocha-rfc232-unit-addon.js b/node-tests/fixtures/component-test/mocha-rfc232-unit-addon.js new file mode 100644 index 00000000000..6e0e48fb188 --- /dev/null +++ b/node-tests/fixtures/component-test/mocha-rfc232-unit-addon.js @@ -0,0 +1,12 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupTest } from 'dummy/tests/helpers'; + +describe('Unit | Component | foo', function () { + setupTest(); + + it('exists', function () { + let component = this.owner.factoryFor('component:foo').create(); + expect(component).to.be.ok; + }); +}); diff --git a/node-tests/fixtures/component-test/rfc232-addon.js b/node-tests/fixtures/component-test/rfc232-addon.js new file mode 100644 index 00000000000..0c22851c05a --- /dev/null +++ b/node-tests/fixtures/component-test/rfc232-addon.js @@ -0,0 +1,26 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +module('Integration | Component | foo', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + assert.dom(this.element).hasText(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + assert.dom(this.element).hasText('template block text'); + }); +}); diff --git a/node-tests/fixtures/component-test/rfc232-unit-addon.js b/node-tests/fixtures/component-test/rfc232-unit-addon.js new file mode 100644 index 00000000000..818671c1285 --- /dev/null +++ b/node-tests/fixtures/component-test/rfc232-unit-addon.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'dummy/tests/helpers'; + +module('Unit | Component | foo', function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + let component = this.owner.factoryFor('component:foo').create(); + assert.ok(component); + }); +}); diff --git a/node-tests/fixtures/controller-test/mocha-rfc232-addon.js b/node-tests/fixtures/controller-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..013290ac0f4 --- /dev/null +++ b/node-tests/fixtures/controller-test/mocha-rfc232-addon.js @@ -0,0 +1,13 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupTest } from 'dummy/tests/helpers'; + +describe('Unit | Controller | foo', function () { + setupTest(); + + // TODO: Replace this with your real tests. + it('exists', function () { + let controller = this.owner.lookup('controller:foo'); + expect(controller).to.be.ok; + }); +}); diff --git a/node-tests/fixtures/controller-test/rfc232-addon.js b/node-tests/fixtures/controller-test/rfc232-addon.js new file mode 100644 index 00000000000..ca8a7adc375 --- /dev/null +++ b/node-tests/fixtures/controller-test/rfc232-addon.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'dummy/tests/helpers'; + +module('Unit | Controller | foo', function (hooks) { + setupTest(hooks); + + // TODO: Replace this with your real tests. + test('it exists', function (assert) { + let controller = this.owner.lookup('controller:foo'); + assert.ok(controller); + }); +}); diff --git a/node-tests/fixtures/helper-test/mocha-rfc232-addon.js b/node-tests/fixtures/helper-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..2b52c2cb647 --- /dev/null +++ b/node-tests/fixtures/helper-test/mocha-rfc232-addon.js @@ -0,0 +1,18 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +describe('Integration | Helper | foo', function () { + setupRenderingTest(); + + // TODO: Replace this with your real tests. + it('renders', async function () { + this.set('inputValue', '1234'); + + await render(hbs`{{foo this.inputValue}}`); + + expect(this.element.textContent.trim()).to.equal('1234'); + }); +}); diff --git a/node-tests/fixtures/helper-test/rfc232-addon.js b/node-tests/fixtures/helper-test/rfc232-addon.js new file mode 100644 index 00000000000..af309a80c63 --- /dev/null +++ b/node-tests/fixtures/helper-test/rfc232-addon.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +module('Integration | Helper | foo', function (hooks) { + setupRenderingTest(hooks); + + // TODO: Replace this with your real tests. + test('it renders', async function (assert) { + this.set('inputValue', '1234'); + + await render(hbs`{{foo this.inputValue}}`); + + assert.dom(this.element).hasText('1234'); + }); +}); diff --git a/node-tests/fixtures/route-test/mocha-rfc232-addon.js b/node-tests/fixtures/route-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..6234ea8e294 --- /dev/null +++ b/node-tests/fixtures/route-test/mocha-rfc232-addon.js @@ -0,0 +1,12 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupTest } from 'dummy/tests/helpers'; + +describe('Unit | Route | foo', function () { + setupTest(); + + it('exists', function () { + let route = this.owner.lookup('route:foo'); + expect(route).to.be.ok; + }); +}); diff --git a/node-tests/fixtures/route-test/rfc232-addon.js b/node-tests/fixtures/route-test/rfc232-addon.js new file mode 100644 index 00000000000..3c342db100a --- /dev/null +++ b/node-tests/fixtures/route-test/rfc232-addon.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'dummy/tests/helpers'; + +module('Unit | Route | foo', function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + let route = this.owner.lookup('route:foo'); + assert.ok(route); + }); +}); diff --git a/node-tests/fixtures/service-test/mocha-rfc232-addon.js b/node-tests/fixtures/service-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..e3e672f970c --- /dev/null +++ b/node-tests/fixtures/service-test/mocha-rfc232-addon.js @@ -0,0 +1,13 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupTest } from 'dummy/tests/helpers'; + +describe('Unit | Service | foo', function () { + setupTest(); + + // TODO: Replace this with your real tests. + it('exists', function () { + let service = this.owner.lookup('service:foo'); + expect(service).to.be.ok; + }); +}); diff --git a/node-tests/fixtures/service-test/rfc232-addon.js b/node-tests/fixtures/service-test/rfc232-addon.js new file mode 100644 index 00000000000..9268712dd82 --- /dev/null +++ b/node-tests/fixtures/service-test/rfc232-addon.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'dummy/tests/helpers'; + +module('Unit | Service | foo', function (hooks) { + setupTest(hooks); + + // TODO: Replace this with your real tests. + test('it exists', function (assert) { + let service = this.owner.lookup('service:foo'); + assert.ok(service); + }); +});