import { helloWorld } from '@/utils/common'
it('hello world func test', () => {
expect(helloWorld()).toEqual('hello world')
})
import { isEven, isOdd } from '@/utils/common'
describe('judge number test', () => {
it('isEven number', () => {
expect(isEven(8)).toBeTruthy()
})
it('isOdd number', () => {
expect(isOdd(9)).toBeTruthy()
})
it('is not even number', () => {
expect(isEven(7)).toBeFalsy()
})
it('is not odd number', () => {
expect(isOdd(6)).toBeFalsy()
})
})
import { asyncGetNumber } from '@/utils/common'
it('async number func', (done) => {
asyncGetNumber(5, (result) => {
expect(result).toBe(15)
done()
})
})
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<h2>Essential Links</h2>
<!--...-->
</div>
</template>
import helloWorld from '@/components/HelloWorld.vue'
import { mount } from '@vue/test-utils'
describe('hello world contain h2 dom', () => {
test('render Essential Links dom value', () => {
const wrapper = mount(helloWorld)
expect(wrapper.find('h2').text()).toBe('Essential Links')
})
})
import { ironRequest } from '@/utils/common'
describe('iron http get test', () => {
it('getBanner.html', async () => {
let { data } = await ironRequest('getBanner.shtml', {}, 'get')
console.log(data)
if (data.returncode === '0') {
expect(typeof data.banners).toBe('object')
} else {
expect(data.returncode).toBe('-1')
}
})
})