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