Skip to content

Commit 19d5ba2

Browse files
authored
Merge pull request #20673 from emberjs/improve-strict-mode-test-coverage
Add some additional coverage for strict mode/internal keywords
2 parents 1a4dd6a + 64597b3 commit 19d5ba2

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

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

+42
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,48 @@ moduleFor(
258258
this.render('<Foo/>');
259259
this.click('button');
260260
}
261+
262+
// Ember currently uses AST plugins to implement certain features that
263+
// glimmer-vm does not natively provide, such as {{#each-in}}, {{outlet}}
264+
// {{mount}} and some features in {{#in-element}}. These rewrites the AST
265+
// and insert private keywords e.g. `{{#each (-each-in)}}`. These tests
266+
// ensures we have _some_ basic coverage for those features in strict mode.
267+
//
268+
// Ultimately, our test coverage for strict mode is quite inadequate. This
269+
// is particularly important as we expect more apps to start adopting the
270+
// feature. Ideally we would run our entire/most of our test suite against
271+
// both strict and resolution modes, and these things would be implicitly
272+
// covered elsewhere, but until then, these coverage are essential.
273+
274+
'@test Can use each-in'() {
275+
let obj = {
276+
foo: 'FOO',
277+
bar: 'BAR',
278+
};
279+
280+
let Foo = defineComponent({ obj }, '{{#each-in obj as |k v|}}[{{k}}:{{v}}]{{/each-in}}');
281+
282+
this.registerComponent('foo', { ComponentClass: Foo });
283+
284+
this.render('<Foo/>');
285+
this.assertHTML('[foo:FOO][bar:BAR]');
286+
this.assertStableRerender();
287+
}
288+
289+
'@test Can use in-element'() {
290+
let getElement = (id) => document.getElementById(id);
291+
292+
let Foo = defineComponent(
293+
{ getElement },
294+
'{{#in-element (getElement "in-element-test")}}before{{/in-element}}after'
295+
);
296+
297+
this.registerComponent('foo', { ComponentClass: Foo });
298+
299+
this.render('[<div id="in-element-test" />][<Foo/>]');
300+
this.assertText('[before][after]');
301+
this.assertStableRerender();
302+
}
261303
}
262304
);
263305

0 commit comments

Comments
 (0)