• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ember-qunit.setupRenderingTest函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ember-qunit.setupRenderingTest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setupRenderingTest函数的具体用法?TypeScript setupRenderingTest怎么用?TypeScript setupRenderingTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setupRenderingTest函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: module

module('Integration | Component | search/search-facet', function(hooks) {
  setupRenderingTest(hooks);

  test('it renders', async function(assert) {
    await createTest(this);
    assert.equal(getTextNoSpaces(this), 'Facet1Value11Value210');
  });

  test('it renders with clear', async function(assert) {
    await createTest(this, { value1: true });
    assert.equal(getTextNoSpaces(this), 'Facet1clearValue11Value210');
  });

  test('clear action', async function(assert) {
    const { wasClearCalled } = await createTest(this, { value1: true });
    assert.equal(getTextNoSpaces(this), 'Facet1clearValue11Value210');
    await click(CLEAR_BTN_SELECTOR);
    assert.ok(wasClearCalled(), 'Clear was called');
  });

  test('facet changed action', async function(assert) {
    const { wasChangedCalled } = await createTest(this, { value1: true });
    assert.equal(getTextNoSpaces(this), 'Facet1clearValue11Value210');
    await click(FACET_OPTION_SELECTOR);
    assert.ok(wasChangedCalled(), 'Clear was called');
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:27,代码来源:search-facet-test.ts


示例2: module

module('Integration | Component | datasets/dataset-fabric-switcher', function(hooks) {
  setupRenderingTest(hooks);

  const contentSelector = '.dataset-fabric-switcher__fabrics';
  const triggerSelector = '.dataset-fabric-switcher__fabric';

  test('component rendering', async function(assert) {
    assert.expect(1);

    await render(hbs`
      {{datasets/dataset-fabric-switcher}}
    `);

    assert.ok(this.element.querySelector('.dataset-fabric-switcher'), 'expected component class exists in DOM');
  });

  test('toggle action shows and hides dropdown', async function(assert) {
    assert.expect(3);

    this.set('urn', nonHdfsUrn);

    await render(hbs`
      {{datasets/dataset-fabric-switcher urn=urn}}
    `);

    assert.notOk(find(contentSelector), 'expected dropdown content class is hidden');

    await triggerEvent(triggerSelector, 'mouseenter');

    assert.ok(find(contentSelector), 'expected dropdown content class is shown');

    await triggerEvent(triggerSelector, 'mouseleave');

    assert.notOk(find(contentSelector), 'expected dropdown content class is hidden');
  });

  test('rendering of fabrics', async function(assert) {
    assert.expect(1);

    this.set('urn', nonHdfsUrn);

    await render(hbs`
      {{datasets/dataset-fabric-switcher urn=urn}}
    `);

    await triggerEvent(triggerSelector, 'mouseenter');

    assert.equal(
      findAll(`${contentSelector} li`).length,
      fabrics.length,
      'expected fabrics shown to equal default list of fabrics'
    );
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:54,代码来源:dataset-fabric-switcher-test.ts


示例3: module

module('Integration | Component | datasets/dataset-relationships', function(hooks) {
  setupRenderingTest(hooks);

  test('component rendering', async function(assert) {
    this.set('urn', nonHdfsUrn);

    await render(hbs`
      {{#datasets/dataset-relationships urn=urn}}
      {{/datasets/dataset-relationships}}
    `);

    assert.ok(this.element, 'renders component into DOM');
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:14,代码来源:dataset-relationships-test.ts


示例4: module

module('Integration | Component | datasets/containers/dataset-lineage-upstreams', function(hooks) {
  setupRenderingTest(hooks);

  test('component rendering', async function(assert) {
    assert.expect(2);

    this.set('urn', nonHdfsUrn);

    await render(hbs`
      {{#datasets/containers/dataset-lineage-upstreams urn=urn}}
        nested container content
      {{/datasets/containers/dataset-lineage-upstreams}}
    `);

    assert.ok(this.element, 'expect component to be rendered in DOM');
    assert.equal(
      this.element.textContent!.trim(),
      'nested container content',
      'expect container to render nested content'
    );
  });

  test('component yielding with a urn', async function(assert) {
    assert.expect(1);

    const { server }: any = this;
    const upstreamCount = 3;

    server.createList('datasetView', upstreamCount);

    this.set('urn', nonHdfsUrn);

    await render(hbs`
      {{#datasets/containers/dataset-lineage-upstreams urn=urn as |container|}}
        <ul class="container-list">
          {{#each container.upstreams}}
            <li></li>
          {{/each}}
        </ul>
      {{/datasets/containers/dataset-lineage-upstreams}}
    `);

    assert.equal(
      findAll('.container-list li')!.length,
      upstreamCount,
      'expect component to yield each upstream dataset'
    );
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:49,代码来源:dataset-lineage-upstreams-test.ts


示例5: module

module('Integration | Component | last-saved-by', function(hooks) {
  setupRenderingTest(hooks);

  test('it renders', async function(assert) {
    await render(hbs`{{last-saved-by}}`);

    assert.ok(
      this.element.textContent!.includes('Never'),
      'it shows a modification time of never when no attributes are passed'
    );
    assert.ok(
      this.element.textContent!.includes('Last Saved:'),
      'it shows a default title when no title attribute is passed'
    );
  });

  test('property rendering', async function(assert) {
    const time = new Date().getTime();
    const actor = 'John Appleseed';
    const title = 'Last Modified';

    this.set('time', time);
    this.set('actor', actor);
    this.set('title', title);

    await render(hbs`{{last-saved-by time=time actor=actor}}`);

    assert.ok(this.element.textContent!.includes(moment(time).fromNow()), 'it shows the last saved time from now');
    assert.ok(this.element.textContent!.includes(actor), 'it shows the actor attribute');

    await render(hbs`{{last-saved-by time=time title=title}}`);

    assert.ok(this.element.textContent!.includes('Last Modified'), 'it shows the passed in title');
    assert.ok(!this.element.textContent!.includes('Last Saved:'), 'it does not show the default title');

    await render(hbs`
      {{#last-saved-by time=time title=title actor=actor as |ls|}}
        <div class="yielded-title">{{ls.title}}</div>
        <div class="yielded-actor">{{ls.actor}}</div>
      {{/last-saved-by}}
    `);

    assert.equal(find('.yielded-title')!.textContent!.trim(), title, 'block usage yields the title');
    assert.equal(find('.yielded-actor')!.textContent!.trim(), actor, 'block usage yields the actor');
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:46,代码来源:last-saved-by-test.ts


示例6: module

module('Integration | Component | search/containers/search-box', function(hooks) {
  setupRenderingTest(hooks);

  test('it renders', async function(assert) {
    await render(hbs`
      {{#search/containers/search-box  as |keyword placeholder onTypeahead onSearch|}}
        template block text
      {{/search/containers/search-box}}
    `);

    assert.equal(getText(this).trim(), 'template block text');
  });

  test('onTypeahead', async function(this: ITestWithMirageContext, assert) {
    const apiHandler = getMirageHandle(this, '/api/v1/autocomplete/datasets', 'get');
    assert.expect(6);

    containerComponentTest(this, async (component: IContainerStub) => {
      // dont return anything with less than 3
      const results1 = await component.onTypeahead('h');
      assert.equal(results1.length, 0);

      // return list
      const results2 = await component.onTypeahead('hol');
      assert.ok(results2.length > 0);

      // cache return
      const results3 = await component.onTypeahead('hol');
      assert.ok(results3.length > 0);
      assert.equal(apiHandler.numberOfCalls, 1, 'cached return');

      // debounce
      component.onTypeahead('hola');
      component.onTypeahead('hola ');
      const results4 = await component.onTypeahead('hola nacho');
      assert.ok(results4.length > 0);
      assert.equal(apiHandler.numberOfCalls, 2, 'App debounces calls');
    });

    await render(hbs`
      {{#search/containers/search-box  as |keyword placeholder onTypeahead onSearch|}}
        {{container-stub onTypeahead=(action onTypeahead)}}
      {{/search/containers/search-box}}
    `);
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:46,代码来源:search-box-test.ts


示例7: module

module('Integration | Component | datasets/containers/data-systems-count', function(hooks) {
  setupRenderingTest(hooks);

  test('component rendering', async function(assert) {
    assert.expect(2);

    await render(hbs`
      {{#datasets/containers/data-systems-count}}
        nested container content
      {{/datasets/containers/data-systems-count}}
    `);

    assert.ok(this.element, 'expect component to be rendered in DOM');
    assert.equal(
      this.element.textContent!.trim(),
      'nested container content',
      'expect container to render nested content'
    );
  });

  test('component rendering with a urn', async function(assert) {
    assert.expect(2);

    const { server }: any = this;
    server.create('datasetsCount');

    this.set('urn', nonHdfsUrn);

    await render(hbs`
      {{#datasets/containers/data-systems-count urn=urn as |container|}}
        {{container.count}}
      {{/datasets/containers/data-systems-count}}
    `);

    assert.ok(this.element, 'expect component to be rendered in DOM');

    const yieldedCount = parseInt(this.element.textContent!);
    assert.ok(yieldedCount >= 0, 'expect yielded value to be a number greater or equal to 0');
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:40,代码来源:data-systems-count-test.ts


示例8: module

module('Integration | Component | metadata-preview', function(hooks) {
  setupRenderingTest(hooks);

  module('image / thumbnail preview', function() {
    module('there is no image in the og data', function(hooks) {
      hooks.beforeEach(async function(this: TestContext) {
        this.set('data', {});
        await render(hbs`{{chat-history/message/embedded-resource/metadata-preview}}`);
      });

      test('no image is shown', function(assert) {
        const img = find('img');

        assert.notOk(img);
      });
    });

    module('there is an image in the og data', function(hooks) {
      hooks.beforeEach(async function(this: TestContext) {
        this.set('data', {
          image: 'https://something',
        });

        await render(hbs`
                     {{chat-history/message/embedded-resource/metadata-preview
                      ogData=data
                     }}
                     `);
      });

      test('an image tag is present', function(assert) {
        const img = find('img');

        assert.ok(img, 'the html tag is present');
        assert.equal(img!.getAttribute('alt'), 'Thumbnail', 'has alt text');
      });
    });
  });
});
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:39,代码来源:-integration-test.ts


示例9: module

module('Integration | Component | get-yield', function(hooks) {
  setupRenderingTest(hooks);

  test('it renders and displays correct value', async function(assert) {
    const myObject = {
      hello: 'world'
    };

    this.setProperties({
      object: myObject,
      property: 'hello'
    });

    await render(hbs`
      {{#get-yield object=object property=property as |text|}}
        {{text}}
      {{/get-yield}}
    `);

    assert.equal(getText(this), 'world');
  });

  test('it renders and displays default value', async function(assert) {
    const myObject = {};

    this.setProperties({
      object: myObject,
      property: 'hello'
    });

    await render(hbs`
      {{#get-yield object=object property=property default='world' as |text|}}
        {{text}}
      {{/get-yield}}
    `);

    assert.equal(getText(this), 'world');
  });
});
开发者ID:alyiwang,项目名称:WhereHows,代码行数:39,代码来源:get-yield-test.ts


示例10: module

module('Integration | Component | embedded-resource', function(hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function() {
    stubService('chat-scroller', {});
  });

  module('shouldRender', function() {
    module('there is nothing to display', function(hooks) {
      disableOpenGraphFetching(hooks, 'hi');

      hooks.beforeEach(async function() {
        await render(hbs`
                     {{chat-history/message/embedded-resource}}
                     `);
      });

      test('nothing is rendered', async function(assert) {
        const text = (this.element as HTMLElement).innerText.trim();

        assert.equal(text, '');
      });
    });

    module('the url is embeddable', function(hooks) {
      disableOpenGraphFetching(hooks);

      hooks.beforeEach(async function(this: TestContext) {
        this.set('someUrl', 'https://i.imgur.com/gCyUdeb.gifv');

        await render(hbs`
                     {{chat-history/message/embedded-resource
                      url=someUrl}}
                     `);
      });

      // TODO: for some reason I can't stub this component's services
      skip('the rendered content is not blank', function(assert) {
        const text = this.element.innerHTML;

        assert.notEqual(text, '', 'html is not empty');
        assert.contains(text, 'imgur');
      });
    });
  });

  module('The media preview is collapsable', async function() {
    module('when collapsed', function() {
      skip('shows nothing', async function() {});

      module('clicking the expand icon', function() {
        skip('shows the content', function() {});
      });
    });

    module('when open', function() {
      skip('the content is visible', function() {});

      module('clicking the collapse icon', function() {
        skip('hides the content', function() {});
      });
    });
  });

  module('Open Graph Data exists', function() {
    skip('renders the image', async function() {});

    skip('there is no sitename', async function() {});
  });

  module('Open Graph Data does not exist', function() {});
});
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:72,代码来源:component-integration-test.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ember-qunit.setupTest函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ember-qunit.setupApplicationTest函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap