Skip to content

Commit e149e32

Browse files
committed
fix: unit test
1 parent fe382f5 commit e149e32

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_js:
44

55
install:
66
- yarn install
7+
- yarn run test:unit
78
- yarn run build:prod
89

910
after_script:

src/utils/sleep.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export function sleep(time = 0) {
22
return new Promise(resolve => {
33
setTimeout(() => {
4-
resolve();
4+
resolve(true);
55
}, time);
66
});
77
}

tests/unit/example.spec.js

-12
This file was deleted.

tests/unit/example.spec.js.map

-1
This file was deleted.

tests/unit/example.spec.ts

-12
This file was deleted.

tests/unit/utils/sleep.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { sleep } from "@/utils/sleep";
2+
3+
describe("sleep", () => {
4+
it("should be executed after around one second", () => {
5+
return sleep(1000).then(status => {
6+
expect(status).toBe(true);
7+
});
8+
});
9+
});

tests/unit/utils/validate.spec.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { isExternal } from "@/utils/validate";
2+
3+
describe("Validate", () => {
4+
it("isExternal", () => {
5+
expect(isExternal("https://github.com/BiYuqi/vue3-element-admin")).toBe(
6+
true
7+
);
8+
expect(isExternal("github.com/BiYuqi/vue3-element-admin")).toBe(false);
9+
expect(isExternal("/dashboard")).toBe(false);
10+
expect(isExternal("./dashboard")).toBe(false);
11+
expect(isExternal("dashboard")).toBe(false);
12+
});
13+
});

0 commit comments

Comments
 (0)