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