Skip to content

Commit

Permalink
Merge pull request #28 from embroider-build/initializer-tests
Browse files Browse the repository at this point in the history
add regression tests for initialisers
  • Loading branch information
mansona authored Jun 27, 2024
2 parents 3472bf7 + 510a5b0 commit db8570a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/default.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('basic functionality', function () {
let result;

try {
result = await execa('pnpm', ['test'], {
result = await execa('pnpm', ['test:ember'], {
cwd: join(tmpDir.path, appName),
});
} catch (err) {
Expand Down
6 changes: 6 additions & 0 deletions tests/fixture/app/initializers/test-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
name: 'test-init',
initialize(application) {
application.__test_init = 'coming from the initializer';
},
};
6 changes: 6 additions & 0 deletions tests/fixture/app/instance-initializers/test-instance-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
name: 'test-instance-initializers',
initialize(instance) {
instance.__instance_test_init = 'set in the instance initializer';
},
};
13 changes: 13 additions & 0 deletions tests/fixture/tests/acceptance/app-init-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { module, test } from 'qunit';
import { getApplication } from '@ember/test-helpers';
import { setupApplicationTest } from '<%= name %>/tests/helpers';

module('Acceptance | app route', function (hooks) {
setupApplicationTest(hooks);

test('loaded initializers /', async function (assert) {
const app = getApplication();
assert.strictEqual([...app._applicationInstances][0].__instance_test_init, 'set in the instance initializer');
assert.strictEqual(app.__test_init, 'coming from the initializer');
});
});

0 comments on commit db8570a

Please sign in to comment.