-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathexample.spec.ts
33 lines (31 loc) · 1.15 KB
/
example.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { expect, assert } from 'chai'
import { shallowMount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'
describe('HelloWorld.vue', () => {
it('renders props.msg when passed', () => {
const msg = 'new message'
const wrapper = shallowMount(HelloWorld, {
props: { msg }
})
expect(wrapper.text()).to.include(msg)
})
})
describe('基本的测试用例', () => {
it('expect检测基本用例是否正确', () => {
const foo = 'bar',
beverages = { tea: ['chai', 'matcha', 'oolong'] }
expect(foo).to.be.a('string')
expect(foo).to.equal('bar')
expect(foo).to.have.lengthOf(3)
expect(beverages).to.have.property('tea').with.lengthOf(3)
})
it('asset检测基本用例是否正确', () => {
const foo = 'bar',
beverages = { tea: ['chai', 'matcha', 'oolong'] }
assert.typeOf(foo, 'string') // without optional message
assert.typeOf(foo, 'string', 'foo is a string') // with optional message
assert.equal(foo, 'bar', 'foo equal `bar`')
assert.lengthOf(foo, 3, 'foo`s value has a length of 3')
assert.lengthOf(beverages.tea, 3, 'beverages has 3 types of tea')
})
})