当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript test-helpers.equalTokens函数代码示例

本文整理汇总了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>');
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:31,代码来源:attributes-test.ts

示例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>");
  });
开发者ID:asakusuma,项目名称:glimmer,代码行数:8,代码来源:component-test.ts


注:本文中的@glimmer/test-helpers.equalTokens函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。