|
1 | 1 | import { describe, test, expect } from "vitest"; |
2 | | -import { isRef, ref, unref } from "vue"; |
| 2 | +import { isRef, ref, reactive, unref } from "vue"; |
3 | 3 |
|
4 | | -import { unrefs, useReducer } from "../src/utils"; |
| 4 | +import { unrefs, useReducer, hasReactive } from "../src/utils"; |
5 | 5 |
|
6 | 6 | describe("unrefs", () => { |
7 | 7 | test("should be defined", () => { |
@@ -71,3 +71,23 @@ describe("useReducer", () => { |
71 | 71 | expect(state.value.num).toBe(2); |
72 | 72 | }); |
73 | 73 | }); |
| 74 | + |
| 75 | +describe("hasReactive", () => { |
| 76 | + test("should be defined", () => { |
| 77 | + expect(hasReactive).toBeDefined(); |
| 78 | + }); |
| 79 | + |
| 80 | + test("check", () => { |
| 81 | + expect(hasReactive(null)).toBeFalsy(); |
| 82 | + expect(hasReactive(undefined)).toBeFalsy(); |
| 83 | + expect(hasReactive({})).toBeFalsy(); |
| 84 | + expect(hasReactive({ 0: 1, 1: 2 })).toBeFalsy(); |
| 85 | + expect(hasReactive([])).toBeFalsy(); |
| 86 | + expect(hasReactive([1, 2, 3])).toBeFalsy(); |
| 87 | + expect(hasReactive([ref(1), 2, 3])).toBeFalsy(); |
| 88 | + expect(hasReactive([ref(1), ref(2), 3])).toBeFalsy(); |
| 89 | + expect(hasReactive([ref(1), ref(2), { a: 1 }])).toBeFalsy(); |
| 90 | + expect(hasReactive([reactive({ a: 1 })])).toBeTruthy(); |
| 91 | + expect(hasReactive([1, 2, reactive({ a: 1 })])).toBeTruthy(); |
| 92 | + }); |
| 93 | +}); |
0 commit comments