Skip to content

Commit 7b212f4

Browse files
Merge pull request #21261 from NullVoxPopuli-ai-agent/fix-node-template-compiler-test-main
Update template-compiler-test for ESM-only build
2 parents e721b5e + fcf7147 commit 7b212f4

1 file changed

Lines changed: 17 additions & 65 deletions

File tree

Lines changed: 17 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,23 @@
1-
import { createRequire } from 'node:module';
2-
import { dirname, join, resolve } from 'node:path';
1+
import { precompile, _buildCompileOptions } from 'ember-source/ember-template-compiler/index.js';
32

4-
const require = createRequire(import.meta.url);
5-
const emberSourceRoot = dirname(require.resolve('ember-source/package.json'));
6-
const distPath = join(emberSourceRoot, 'dist');
7-
8-
let templateCompiler;
9-
10-
QUnit.module('ember-template-compiler.js', function () {
11-
QUnit.module('modern', function (hooks) {
12-
hooks.beforeEach(function () {
13-
this.templateCompilerPath = resolve(join(distPath, 'ember-template-compiler.js'));
14-
templateCompiler = require(this.templateCompilerPath);
15-
});
16-
17-
hooks.afterEach(function () {
18-
// clear the previously cached version of this module
19-
delete require.cache[this.templateCompilerPath];
20-
});
21-
22-
QUnit.test('can be required', function (assert) {
23-
assert.strictEqual(
24-
typeof templateCompiler.precompile,
25-
'function',
26-
'precompile function is present'
27-
);
28-
assert.strictEqual(
29-
typeof templateCompiler.compile,
30-
'function',
31-
'compile function is present'
32-
);
33-
});
34-
35-
QUnit.test('can access _Ember.ENV (private API used by ember-cli-htmlbars)', function (assert) {
36-
assert.equal(typeof templateCompiler._Ember.ENV, 'object', '_Ember.ENV is present');
37-
assert.notEqual(typeof templateCompiler._Ember.ENV, null, '_Ember.ENV is not null');
38-
});
39-
40-
QUnit.test('_Ember.ENV (private API used by ember-cli-htmlbars) is stable', function (assert) {
41-
assert.strictEqual(
42-
templateCompiler._Ember.ENV,
43-
templateCompiler._Ember.ENV,
44-
'_Ember.ENV is stable'
45-
);
46-
});
3+
QUnit.module('ember-template-compiler', function () {
4+
QUnit.test('precompile is available', function (assert) {
5+
assert.strictEqual(typeof precompile, 'function', 'precompile function is present');
6+
});
477

48-
QUnit.test(
49-
'can access _Ember.FEATURES (private API used by ember-cli-htmlbars)',
50-
function (assert) {
51-
assert.equal(
52-
typeof templateCompiler._Ember.FEATURES,
53-
'object',
54-
'_Ember.FEATURES is present'
55-
);
56-
assert.notEqual(
57-
typeof templateCompiler._Ember.FEATURES,
58-
null,
59-
'_Ember.FEATURES is not null'
60-
);
61-
}
8+
QUnit.test('_buildCompileOptions is available', function (assert) {
9+
assert.strictEqual(
10+
typeof _buildCompileOptions,
11+
'function',
12+
'_buildCompileOptions function is present'
6213
);
14+
});
6315

64-
QUnit.test(
65-
'can access _Ember.VERSION (private API used by ember-cli-htmlbars)',
66-
function (assert) {
67-
assert.equal(typeof templateCompiler._Ember.VERSION, 'string', '_Ember.VERSION is present');
68-
}
69-
);
16+
QUnit.test('precompile produces a valid template spec', function (assert) {
17+
let result = precompile('<h1>Hello</h1>');
18+
assert.strictEqual(typeof result, 'string', 'precompile returns a string');
19+
20+
let parsed = JSON.parse(result);
21+
assert.strictEqual(typeof parsed, 'object', 'precompile output is valid JSON');
7022
});
7123
});

0 commit comments

Comments
 (0)