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

TypeScript test-utils.mount函数代码示例

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

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



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

示例1: test

  test('should change slide', () => {
    const wrapper = mount(VueCarousel,
                          {
                            localVue,
                            propsData: {
                              images,
                              intervalDuration: 10,
                            },
                          },
    ) as any;

    expect(wrapper.vm.currentSlide).toBe(0);

    wrapper.vm.changeSlide();
    expect(wrapper.vm.currentSlide).toBe(1);

    wrapper.vm.changeSlide();
    expect(wrapper.vm.currentSlide).toBe(2);

    wrapper.vm.changeSlide();
    expect(wrapper.vm.currentSlide).toBe(0);

    wrapper.vm.pause = true;
    wrapper.vm.changeSlide();
    expect(wrapper.vm.currentSlide).toBe(0);

    wrapper.vm.pause = false;
    wrapper.vm.changeSlide();
    expect(wrapper.vm.currentSlide).toBe(1);
  });
开发者ID:trungx,项目名称:vue-starter,代码行数:30,代码来源:VueCarousel.spec.ts


示例2: test

  test('should increment and decrement', () => {
    const actions = {
      increment: jest.fn(),
      decrement: jest.fn(),
    };
    const store = new Vuex.Store({
                                   modules: {
                                     counter: {
                                       namespaced: true,
                                       getters:    {
                                         count:            () => 0,
                                         incrementPending: () => false,
                                         decrementPending: () => false,
                                       },
                                       actions,
                                     },
                                   },
                                 });
    const wrapper: any = mount(Counter, {
      store,
      localVue,
      i18n,
    });

    wrapper.vm.increment();
    expect(actions.increment).toHaveBeenCalled();

    wrapper.vm.decrement();
    expect(actions.decrement).toHaveBeenCalled();
  });
开发者ID:trungx,项目名称:vue-starter,代码行数:30,代码来源:Counter.spec.ts


示例3: test

  test('renders component and not truncate text', () => {
    const getComputedStyle = window.getComputedStyle;

    (window as any).getComputedStyle = () => {
      return {
        'line-height': 0,
      };
    };

    const wrapper = mount(VueTruncate,
                          {
                            i18n,
                            localVue,
                            slots:     {
                              default: `
                                Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et<br/>
  dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet<br/>
  clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,<br/>
  consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,<br/>
  sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,<br/>
  no sea takimata sanctus est Lorem ipsum dolor sit amet.`,
                            },
                            propsData: {
                              lines: 1,
                            },
                          },
    ) as any;

    expect(wrapper.isVueInstance()).toBeTruthy();
    expect(wrapper.vm.isTruncated).toBeFalsy();

    (window as any).getComputedStyle = getComputedStyle;
  });
开发者ID:trungx,项目名称:vue-starter,代码行数:33,代码来源:VueTruncate.spec.ts


示例4: test

  test('should handle key events on left handle with single range', () => {
    const wrapper = mount(VueSlider,
                          {
                            localVue,
                            propsData: {
                              min:    0,
                              max:    100,
                              values: [10],
                            },
                          }) as any;

    wrapper.vm.currentSlider = 0;

    wrapper.vm.onKeyDown({ code: 'ArrowLeft' });
    expect(wrapper.vm.currentMin).toBe(5);

    wrapper.vm.onKeyDown({ code: 'ArrowLeft' });
    expect(wrapper.vm.currentMin).toBe(0);

    wrapper.vm.onKeyDown({ code: 'ArrowLeft' });
    expect(wrapper.vm.currentMin).toBe(0);

    wrapper.vm.currentMin = 90;

    wrapper.vm.onKeyDown({ code: 'ArrowRight' });
    expect(wrapper.vm.currentMin).toBe(95);

    wrapper.vm.onKeyDown({ code: 'ArrowRight' });
    expect(wrapper.vm.currentMin).toBe(100);

    wrapper.vm.onKeyDown({ code: 'ArrowRight' });
    expect(wrapper.vm.currentMin).toBe(100);
  });
开发者ID:trungx,项目名称:vue-starter,代码行数:33,代码来源:VueSlider.spec.ts


示例5: test

  test('should animate enter', (done) => {
    const wrapper = mount(CollapseAnimation,
                          {
                            localVue,
                            slots: {
                              default: '<p>TEST</p>',
                            },
                          });

    const testElement: HTMLElement = wrapper.find('p').element;

    (testElement as any).getClientRects = () => {
      return {
        item: () => {
          return {
            height: 100,
          };
        },
      };
    };

    (wrapper as any).vm.leave(testElement, () => {
      expect(testElement.style.height).toBe('');
      expect(testElement.style.opacity).toBe('0');
      done();
    });
  });
开发者ID:trungx,项目名称:vue-starter,代码行数:27,代码来源:CollapseAnimation.spec.ts


示例6: test

  test('renders component', () => {
    (window as any).HTMLCanvasElement.prototype.getContext = jest.fn();

    const wrapper = mount(Stage, {
      localVue,
      i18n,
      propsData: {
        disableParticles: true,
      },
    });

    expect(wrapper.find('h1').text()).toBe('vue-starter');

    (wrapper as any).vm.$refs.stage.getClientRects = () => {
      return {
        length: 1,
        item() {
          return {
            width:  100,
            height: 100,
          };
        },
      };
    };

    (wrapper as any).vm.handleResize();
  });
开发者ID:trungx,项目名称:vue-starter,代码行数:27,代码来源:Stage.spec.ts


示例7: test

  test('should sort data', () => {
    const wrapper = mount(VueDataTable,
                          {
                            i18n,
                            localVue,
                            propsData: {
                              header,
                              data,
                            },
                          },
    ) as any;

    wrapper.vm.sortKey = 'firstname';

    expect(wrapper.vm.sortedData[0].firstname).toBe('Julia');
    expect(wrapper.vm.sortedData[1].firstname).toBe('Julia');
    expect(wrapper.vm.sortedData[2].firstname).toBe('Julia');
    expect(wrapper.vm.sortedData[3].firstname).toBe('Julia');

    wrapper.vm.sortDirection = 'desc';

    expect(wrapper.vm.sortedData[0].firstname).toBe('Toni');
    expect(wrapper.vm.sortedData[1].firstname).toBe('Toni');
    expect(wrapper.vm.sortedData[2].firstname).toBe('Toni');
    expect(wrapper.vm.sortedData[3].firstname).toBe('Toni');
  });
开发者ID:trungx,项目名称:vue-starter,代码行数:26,代码来源:VueDataTable.spec.ts


示例8: test

  test('setResultContainerHeight', () => {
    const wrapper: any = mount(VueAutocomplete, {
      localVue,
      i18n,
      propsData: {
        placeholder: 'Type something',
        maxOptions:  10,
      },
    });

    wrapper.vm.isOpen = true;
    wrapper.vm.$refs.resultContainer = {
      firstChild: {
        offsetHeight: 10,
      },
    };

    wrapper.vm.setResultContainerHeight();
    expect(wrapper.vm.resultContainerHeight).toBe(10);

    wrapper.setProps({ options: AutocompleteOptionsFixture });

    wrapper.vm.setResultContainerHeight();
    expect(wrapper.vm.resultContainerHeight).toBe(90);

    wrapper.setProps({ maxOptions: 5 });

    wrapper.vm.setResultContainerHeight();
    expect(wrapper.vm.resultContainerHeight).toBe(55);
  });
开发者ID:trungx,项目名称:vue-starter,代码行数:30,代码来源:VueAutocomplete.spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript test-utils.shallowMount函数代码示例发布时间:2022-05-28
下一篇:
TypeScript refs._document类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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