本文整理汇总了TypeScript中@glimmer/test-helpers.equalTokens函数的典型用法代码示例。如果您正苦于以下问题:TypeScript equalTokens函数的具体用法?TypeScript equalTokens怎么用?TypeScript equalTokens使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了equalTokens函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('does not set null properties initially', assert => {
let template = compile('<div title={{isNull}} /><div title={{isNotNull}}></div>');
render(template, { isNull: null, isNotNull: 'hello' });
let firstElement = root.firstChild as Element;
let secondElement = root.lastChild as Element;
assert.ok(!firstElement.hasAttribute('title'));
assert.equal(readDOMAttr(secondElement, 'title'), 'hello');
equalTokens(root, '<div></div><div title="hello"></div>');
rerender({ isNull: 'hey', isNotNull: 'hello' });
assert.equal(readDOMAttr(firstElement, 'title'), 'hey');
assert.equal(readDOMAttr(secondElement, 'title'), 'hello');
equalTokens(root, '<div title="hey"></div><div title="hello"></div>');
rerender({ isNull: 'hey', isNotNull: 'world' });
assert.equal(readDOMAttr(firstElement, 'title'), 'hey');
assert.equal(readDOMAttr(secondElement, 'title'), 'world');
equalTokens(root, '<div title="hey"></div><div title="world"></div>');
rerender({ isNull: null, isNotNull: 'hello' });
assert.equal(readDOMAttr(secondElement, 'title'), 'hello');
assert.equal(readDOMAttr(firstElement, 'title'), '');
assert.equal(readDOMAttr(firstElement, 'title'), nativeValueForElementProperty('div', 'title', ''));
equalTokens(root, '<div></div><div title="hello"></div>');
});
示例2: test
test('creating a new component passing args', assert => {
let template = compile("<my-component @arg1='hello - ' color='{{color}}'>hello!</my-component>");
render(template, { color: 'red' });
equalTokens(root, "<div color='red'>hello - hello!</div>");
rerender({ color: 'green' });
equalTokens(root, "<div color='green'>hello - hello!</div>");
});