本文整理匯總了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>');
});