From 94a0ee9f6dd62d7b0f308bdc8ca3482f2d4fb9b6 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Wed, 28 Feb 2024 17:42:22 +0000 Subject: [PATCH] fix compat-namespaced-app --- tests/scenarios/compat-namespaced-app-test.ts | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tests/scenarios/compat-namespaced-app-test.ts b/tests/scenarios/compat-namespaced-app-test.ts index 45b0ab298c..44c17a46f2 100644 --- a/tests/scenarios/compat-namespaced-app-test.ts +++ b/tests/scenarios/compat-namespaced-app-test.ts @@ -42,21 +42,39 @@ appScenarios hooks.beforeEach(assert => { expectFile = expectFilesAt(readFileSync(join(app.dir, 'dist/.stage2-output'), 'utf8'), { qunit: assert }); }); - test(`app js location`, function () { - expectFile('assets/@ef4/namespaced-app.js').exists(); - }); - test(`imports within app js`, function () { + test(`imports within app js`, function (assert) { expectAudit - .module('assets/@ef4/namespaced-app.js') + .module('./node_modules/.embroider/rewritten-app/index.html') + .resolves('./@embroider/core/entrypoint') + .toModule() .resolves('./-embroider-implicit-modules.js') .toModule() .resolves('my-addon/my-implicit-module.js') .to('./node_modules/my-addon/my-implicit-module.js'); - expectAudit.module('assets/@ef4/namespaced-app.js').codeContains(` - d('@ef4/namespaced-app/app', function(){ return i('@ef4/namespaced-app/app.js');}); - `); + expectAudit + .module('./node_modules/.embroider/rewritten-app/index.html') + .resolves('./@embroider/core/entrypoint') + .toModule() + .withContents(contents => { + const [, amdModuleVariable] = + /import (amdModule\d+) from "@embroider-dep\/@ef4\/namespaced-app\/templates\/application.hbs"/.exec( + contents + ) ?? []; + + if (!amdModuleVariable) { + throw new Error('could not find the application.hbs import in entrypoint'); + } + + assert.codeContains( + contents, + `d("@ef4/namespaced-app/templates/application", function () { + return ${amdModuleVariable}; + });` + ); + return true; + }, 'module imports from the correct place and exports object with the right key'); }); test(`app css location`, function () {