Skip to content

Commit 70ceeef

Browse files
Merge pull request #21281 from NullVoxPopuli-ai-agent/nvp/remove-compile-export
Remove compile from internal-test-helpers public exports
2 parents 216139d + 55c0721 commit 70ceeef

File tree

6 files changed

+50
-30
lines changed

6 files changed

+50
-30
lines changed

packages/@ember/-internals/glimmer/tests/integration/components/angle-bracket-invocation-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import EmberObject from '@ember/object';
44

55
import { set, setProperties } from '@ember/object';
66

7-
import { Component, compile } from '../../utils/helpers';
7+
import { Component } from '../../utils/helpers';
88
import { template } from '@ember/template-compiler/runtime';
99
import templateOnly from '@ember/component/template-only';
1010
import { precompileTemplate } from '@ember/template-compilation';
@@ -679,7 +679,7 @@ moduleFor(
679679
// attempting to compile this template will throw
680680
this.owner.register(
681681
'component:test-harness',
682-
setComponentTemplate(compile('<foo.bar />'), class extends Component {})
682+
template('<foo.bar />', { component: class extends Component {}, strictMode: false })
683683
);
684684
}, /Error: You used foo.bar as a tag name, but foo is not in scope/);
685685
}

packages/@ember/-internals/glimmer/tests/integration/components/append-test.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { set } from '@ember/object';
44
import { setComponentTemplate } from '@glimmer/manager';
55

66
import { precompileTemplate } from '@ember/template-compilation';
7-
import { Component, compile } from '../../utils/helpers';
7+
import { Component } from '../../utils/helpers';
88

99
class AbstractAppendTest extends RenderingTestCase {
1010
constructor() {
@@ -44,7 +44,7 @@ class AbstractAppendTest extends RenderingTestCase {
4444

4545
let componentsByName = {};
4646

47-
let createLogger = (name, template) => {
47+
let createLogger = (name, compiledTemplate) => {
4848
function pushHook(hookName) {
4949
hooks.push([name, hookName]);
5050
}
@@ -112,7 +112,7 @@ class AbstractAppendTest extends RenderingTestCase {
112112

113113
let local = class extends LoggerComponent {};
114114

115-
setComponentTemplate(compile(template), local);
115+
setComponentTemplate(compiledTemplate, local);
116116

117117
this.owner.register(`component:${name}`, local);
118118

@@ -121,20 +121,20 @@ class AbstractAppendTest extends RenderingTestCase {
121121

122122
createLogger(
123123
'x-parent',
124-
`[parent: {{this.foo}}]
124+
precompileTemplate(`[parent: {{this.foo}}]
125125
[parent: {{this.parentValue}}
126126
127127
<XChild @bar={{this.foo}} @childValue={{this.childValue}}>
128128
[yielded: {{this.foo}}]
129129
</XChild>
130-
`
130+
`)
131131
);
132132
createLogger(
133133
'x-child',
134-
`
134+
precompileTemplate(`
135135
[child: {{this.bar}}]
136136
[child: {{this.childValue}}]
137-
{{yield}}`
137+
{{yield}}`)
138138
);
139139

140140
this.render(
@@ -353,8 +353,8 @@ class AbstractAppendTest extends RenderingTestCase {
353353

354354
this.owner.register(`component:${name}`, ExtendedClass);
355355

356-
if (typeof resolveableTemplate === 'string') {
357-
this.owner.register(`template:components/${name}`, compile(resolveableTemplate));
356+
if (resolveableTemplate) {
357+
this.owner.register(`template:components/${name}`, resolveableTemplate);
358358
}
359359
};
360360

@@ -363,16 +363,17 @@ class AbstractAppendTest extends RenderingTestCase {
363363
layoutName = 'components/x-parent';
364364
},
365365

366-
resolveableTemplate:
367-
'[parent: {{this.foo}}]{{#x-child bar=this.foo}}[yielded: {{this.foo}}]{{/x-child}}',
366+
resolveableTemplate: precompileTemplate(
367+
'[parent: {{this.foo}}]{{#x-child bar=this.foo}}[yielded: {{this.foo}}]{{/x-child}}'
368+
),
368369
});
369370

370371
registerLoggerComponent('x-child', {
371372
ComponentClass: class extends Component {
372373
tagName = '';
373374
},
374375

375-
resolveableTemplate: '[child: {{this.bar}}]{{yield}}',
376+
resolveableTemplate: precompileTemplate('[child: {{this.bar}}]{{yield}}'),
376377
});
377378

378379
let XParent;

packages/@ember/-internals/glimmer/tests/integration/components/render-component-test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313

1414
import { Input, Textarea } from '@ember/component';
1515
import { precompileTemplate } from '@ember/template-compilation';
16-
import { compile } from 'internal-test-helpers';
1716
import { template } from '@ember/template-compiler/runtime';
17+
import { template as compileTimeTemplate } from '@ember/template-compiler';
1818
import { setComponentTemplate } from '@glimmer/manager';
1919
import templateOnly from '@ember/component/template-only';
2020
import { array, concat, fn, get, hash, on } from '@glimmer/runtime';
@@ -242,12 +242,20 @@ moduleFor(
242242
this.renderComponent(Root, { expect: '<div>Hello, world!</div>' });
243243
}
244244

245-
'@test Can shadow keywords'() {
246-
let ifComponent = setComponentTemplate(precompileTemplate('Hello, world!'), templateOnly());
247-
let Bar = setComponentTemplate(
248-
compile('{{#if}}{{/if}}', { strictMode: true }, { if: ifComponent }),
249-
templateOnly()
250-
);
245+
'@test Can shadow keywords (runtime)'() {
246+
let each = setComponentTemplate(precompileTemplate('Hello, world!'), templateOnly());
247+
let Bar = template('{{#each}}{{/each}}', {
248+
scope: () => ({ each }),
249+
});
250+
251+
this.renderComponent(Bar, { expect: 'Hello, world!' });
252+
}
253+
254+
'@test Can shadow keywords (compile-time)'() {
255+
let each = setComponentTemplate(precompileTemplate('Hello, world!'), templateOnly());
256+
let Bar = compileTimeTemplate('{{#each}}{{/each}}', {
257+
scope: () => ({ each }),
258+
});
251259

252260
this.renderComponent(Bar, { expect: 'Hello, world!' });
253261
}

packages/@ember/-internals/glimmer/tests/integration/components/strict-mode-test.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
compile,
32
moduleFor,
43
ApplicationTestCase,
54
RenderingTestCase,
@@ -10,6 +9,8 @@ import {
109
import { Input, Textarea } from '@ember/component';
1110
import { LinkTo } from '@ember/routing';
1211
import { precompileTemplate } from '@ember/template-compilation';
12+
import { template } from '@ember/template-compiler/runtime';
13+
import { template as compileTimeTemplate } from '@ember/template-compiler';
1314
import { setComponentTemplate } from '@glimmer/manager';
1415
import templateOnly from '@ember/component/template-only';
1516
import { hash, array, concat, get, on, fn } from '@glimmer/runtime';
@@ -60,12 +61,24 @@ moduleFor(
6061
this.assertStableRerender();
6162
}
6263

63-
'@test Can shadow keywords'() {
64-
let ifComponent = setComponentTemplate(precompileTemplate('Hello, world!'), templateOnly());
65-
let Bar = setComponentTemplate(
66-
compile('{{#if}}{{/if}}', { strictMode: true }, { if: ifComponent }),
67-
templateOnly()
68-
);
64+
'@test Can shadow keywords (runtime)'() {
65+
let each = setComponentTemplate(precompileTemplate('Hello, world!'), templateOnly());
66+
let Bar = template('{{#each}}{{/each}}', {
67+
scope: () => ({ each }),
68+
});
69+
70+
this.owner.register('component:bar', Bar);
71+
72+
this.render('<Bar/>');
73+
this.assertHTML('Hello, world!');
74+
this.assertStableRerender();
75+
}
76+
77+
'@test Can shadow keywords (compile-time)'() {
78+
let each = setComponentTemplate(precompileTemplate('Hello, world!'), templateOnly());
79+
let Bar = compileTimeTemplate('{{#each}}{{/each}}', {
80+
scope: () => ({ each }),
81+
});
6982

7083
this.owner.register('component:bar', Bar);
7184

packages/@ember/-internals/glimmer/tests/utils/helpers.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export { precompile } from 'ember-template-compiler';
2-
export { compile } from 'internal-test-helpers';
32

43
export {
54
Helper,

packages/internal-test-helpers/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export {
2020
} from './lib/ember-dev/deprecation';
2121
export { defineSimpleHelper, defineSimpleModifier } from './lib/define-template-values';
2222
export { testIf, testUnless } from './lib/conditional-test';
23-
export { default as compile } from './lib/compile';
2423
export { equalsElement, classes, styles, regex } from './lib/matchers';
2524
export { runAppend, runDestroy, runTask, runTaskNext, runLoopSettled } from './lib/run';
2625
export { getContext, setContext, unsetContext } from './lib/test-context';

0 commit comments

Comments
 (0)