本文整理汇总了TypeScript中@vue/test-utils.shallowMount函数的典型用法代码示例。如果您正苦于以下问题:TypeScript shallowMount函数的具体用法?TypeScript shallowMount怎么用?TypeScript shallowMount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shallowMount函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('renders props.msg when passed', () => {
const msg = 'new message';
const wrapper = shallowMount(HelloWorld, {
propsData: { msg },
});
expect(wrapper.text()).to.include(msg);
});
示例2: it
it('should work', () => {
const wrapper = shallowMount(TaskListItem, {
propsData: {
task: {
id: 'task-one',
text: 'the task one'
}
}
});
expect(wrapper.text()).to.contain('id=task-one');
expect(wrapper.text()).to.contain('text=the task one');
});
示例3: test
test('renders component with loader', () => {
const wrapper: any = shallowMount(VueAutocomplete, {
localVue,
i18n,
propsData: {
placeholder: 'Type something',
options: AutocompleteOptionsFixture,
isLoading: true,
},
});
expect(wrapper.findAll(VueLoader)).toHaveLength(1);
});
示例4: it
it ('should render correct contents', (done) => {
const wrapper = shallowMount(Home, {
propsData: { name: 'Vue' },
});
const vm = wrapper.vm as any;
expect(vm.name).toBe('Vue');
expect(vm.$el.querySelector('input')!.type).toBe('text');
expect(vm.$el.querySelector('h3.result')!.textContent).toBe('');
vm.result = 'Bye Vue';
expect(vm.$el.querySelector('h3.result')!.textContent).toBe('Bye Vue');
done();
});
示例5: test
test('renders onSubmit', (done) => {
const wrapper = shallowMount(FormExample,
{
i18n,
localVue,
},
) as any;
wrapper.vm.onSubmit();
expect(wrapper.vm.isLoading).toBeTruthy();
setTimeout(() => {
expect(wrapper.vm.isLoading).toBeFalsy();
done();
}, 550);
});
示例6: test
test('renders component', () => {
const store = new Vuex.Store({
state: {
app: {
config: {
features: {
disableParticles: false,
},
},
},
},
});
const wrapper = shallowMount(Home, {
store,
localVue,
i18n,
});
expect(wrapper.findAll(Stage)).toHaveLength(1);
expect(wrapper.findAll(DevEx)).toHaveLength(1);
expect(wrapper.findAll(EnterpriseReady)).toHaveLength(1);
expect(wrapper.findAll(UserExperience)).toHaveLength(1);
expect(wrapper.findAll(QuickStart)).toHaveLength(1);
});
示例7: it
it ('should render correct contents', () => {
const wrapper = shallowMount(View1) as any;
expect(wrapper.vm.$el.querySelector('h3')!.textContent).toBe('This is View 1');
});