first commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { shallowMount } from "@vue/test-utils"
|
||||
import { describe, expect, it } from "vitest"
|
||||
import Notify from "@/components/Notify/index.vue"
|
||||
import NotifyList from "@/components/Notify/NotifyList.vue"
|
||||
|
||||
describe("Notify", () => {
|
||||
it("正常渲染", () => {
|
||||
const wrapper = shallowMount(Notify)
|
||||
expect(wrapper.classes("notify")).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("NotifyList", () => {
|
||||
it("List 长度为 0", () => {
|
||||
const wrapper = shallowMount(NotifyList, {
|
||||
props: {
|
||||
list: []
|
||||
}
|
||||
})
|
||||
expect(wrapper.find("el-empty").exists()).toBe(true)
|
||||
})
|
||||
it("List 长度不为 0", () => {
|
||||
const wrapper = shallowMount(NotifyList, {
|
||||
props: {
|
||||
list: [
|
||||
{
|
||||
title: ""
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
expect(wrapper.find("el-empty").exists()).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
/**
|
||||
* @description 该文件所有示例均是为了向你演示 Vitest 最基本的用法
|
||||
* @link https://cn.vitest.dev/api
|
||||
* @api describe: 形成一个作用域
|
||||
* @api test/it: 定义了一组关于测试期望的方法,它接收测试名称和一个含有测试期望的函数
|
||||
* @api expect: 用来创建断言
|
||||
* @api toBe: 可以用于断言原始类型是否相等,或者对象是否共享相同的引用
|
||||
* @api toEqual: 断言实际值是否等于接收到的值或具有相同的结构(如果是对象,则递归比较它们)
|
||||
*/
|
||||
|
||||
const author1 = {
|
||||
name: "pany",
|
||||
email: "939630029@qq.com",
|
||||
url: "https://github.com/pany-ang"
|
||||
}
|
||||
|
||||
const author2 = {
|
||||
name: "pany",
|
||||
email: "939630029@qq.com",
|
||||
url: "https://github.com/pany-ang"
|
||||
}
|
||||
|
||||
describe("这里填写作用域名称", () => {
|
||||
it("测试基础数据类型", () => {
|
||||
expect(1 + 1).toBe(2)
|
||||
})
|
||||
it("测试引用类型", () => {
|
||||
expect(author1).toEqual(author2)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest"
|
||||
import { isArray } from "@/utils/validate"
|
||||
|
||||
describe("isArray", () => {
|
||||
it("String", () => {
|
||||
expect(isArray("")).toBe(false)
|
||||
})
|
||||
it("Number", () => {
|
||||
expect(isArray(1)).toBe(false)
|
||||
})
|
||||
it("Boolean", () => {
|
||||
expect(isArray(true)).toBe(false)
|
||||
})
|
||||
it("Null", () => {
|
||||
expect(isArray(null)).toBe(false)
|
||||
})
|
||||
it("Undefined", () => {
|
||||
expect(isArray(undefined)).toBe(false)
|
||||
})
|
||||
it("Symbol", () => {
|
||||
expect(isArray(Symbol())).toBe(false)
|
||||
})
|
||||
it("BigInt", () => {
|
||||
expect(isArray(BigInt(1))).toBe(false)
|
||||
})
|
||||
it("Object", () => {
|
||||
expect(isArray({})).toBe(false)
|
||||
})
|
||||
it("Array Object", () => {
|
||||
expect(isArray([])).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user