From 510a5b029cea98b1932de6e6c0a55bc32e09bafb Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Wed, 5 Jun 2024 13:27:56 +0100 Subject: [PATCH] add failing tests for initialisers --- tests/default.test.mjs | 2 +- tests/fixture/app/initializers/test-init.js | 6 ++++++ .../app/instance-initializers/test-instance-init.js | 6 ++++++ tests/fixture/tests/acceptance/app-init-test.js | 13 +++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/fixture/app/initializers/test-init.js create mode 100644 tests/fixture/app/instance-initializers/test-instance-init.js create mode 100644 tests/fixture/tests/acceptance/app-init-test.js diff --git a/tests/default.test.mjs b/tests/default.test.mjs index 0036162..7314c40 100644 --- a/tests/default.test.mjs +++ b/tests/default.test.mjs @@ -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) { diff --git a/tests/fixture/app/initializers/test-init.js b/tests/fixture/app/initializers/test-init.js new file mode 100644 index 0000000..f7bb350 --- /dev/null +++ b/tests/fixture/app/initializers/test-init.js @@ -0,0 +1,6 @@ +export default { + name: 'test-init', + initialize(application) { + application.__test_init = 'coming from the initializer'; + }, +}; diff --git a/tests/fixture/app/instance-initializers/test-instance-init.js b/tests/fixture/app/instance-initializers/test-instance-init.js new file mode 100644 index 0000000..856fe8c --- /dev/null +++ b/tests/fixture/app/instance-initializers/test-instance-init.js @@ -0,0 +1,6 @@ +export default { + name: 'test-instance-initializers', + initialize(instance) { + instance.__instance_test_init = 'set in the instance initializer'; + }, +}; diff --git a/tests/fixture/tests/acceptance/app-init-test.js b/tests/fixture/tests/acceptance/app-init-test.js new file mode 100644 index 0000000..72a3209 --- /dev/null +++ b/tests/fixture/tests/acceptance/app-init-test.js @@ -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'); + }); +});