本文整理汇总了TypeScript中glimmer-test-helpers.TestEnvironment类的典型用法代码示例。如果您正苦于以下问题:TypeScript TestEnvironment类的具体用法?TypeScript TestEnvironment怎么用?TypeScript TestEnvironment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestEnvironment类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
window['$BENCH'].render = function() {
let { env, context, template, TestDynamicScope } = this;
let frag = document.createDocumentFragment();
env.begin();
template.render(context, env, { appendTo: frag, dynamicScope: new TestDynamicScope(null) });
env.commit();
return frag;
};
示例2: function
test("Morphs are escaped correctly", function() {
env.registerHelper('testing-unescaped', function(params) {
return params[0];
});
env.registerHelper('testing-escaped', function(params, hash) {
return params[0];
});
compilesTo('<div>{{{testing-unescaped "<span>hi</span>"}}}</div>', '<div><span>hi</span></div>');
compilesTo('<div>{{testing-escaped "<hi>"}}</div>', '<div><hi></div>');
});
示例3: rerender
function rerender(context: Object = {}, params: RerenderParams = { assertStable: false }) {
let snapshot;
if (params.assertStable) {
snapshot = generateSnapshot(root);
}
self.update(opaque(context));
env.begin();
result.rerender();
env.commit();
if (params.assertStable) {
equalSnapshots(generateSnapshot(root), snapshot);
}
}
示例4: compile
QUnit.test('changing dynamic partial and changing references', assert => {
let template = compile(`{{partial name}}`);
env.registerPartial('weezy', `Ain't my birthday but I got my {{item}} on the cake.`);
env.registerPartial('birdman', `Respeck my {{noun}}. When my {{noun}} come up put some respeck on it.`);
render(template, { name: 'weezy', item: 'partial' });
equalTokens(root, `Ain't my birthday but I got my partial on the cake.`);
rerender({ name: 'birdman', noun: 'name' });
equalTokens(root, `Respeck my name. When my name come up put some respeck on it.`);
rerender({ name: 'birdman', noun: 'name' }, { assertStable: true });
equalTokens(root, `Respeck my name. When my name come up put some respeck on it.`);
});
示例5: function
test("GH#13999 The compiler can handle components with undefined named arguments", function() {
env.registerHelper('say-hello', function() {
return 'hello';
});
compilesTo('<div>{{say-hello foo=undefined}}</div>', '<div>hello</div>');
});