|
1 | | -import { describe, it, expect } from "bun:test"; |
2 | | -import { |
3 | | - throws, |
4 | | - assert, |
5 | | - strictEqual, |
6 | | - createCallCheckCtx, |
7 | | - createDoneDotAll, |
8 | | -} from "./node-test-helpers"; |
| 1 | +// import { describe, it, expect } from "bun:test"; |
| 2 | +// import { |
| 3 | +// throws, |
| 4 | +// assert, |
| 5 | +// strictEqual, |
| 6 | +// createCallCheckCtx, |
| 7 | +// createDoneDotAll, |
| 8 | +// } from "./node-test-helpers"; |
9 | 9 |
|
10 | | -describe("NodeTestHelpers.throws()", () => { |
11 | | - it("should pass when the function throws", () => { |
12 | | - throws(() => { |
13 | | - throw new Error("THROWN!"); |
14 | | - }); |
15 | | - }); |
| 10 | +// describe("NodeTestHelpers.throws()", () => { |
| 11 | +// it("should pass when the function throws", () => { |
| 12 | +// throws(() => { |
| 13 | +// throw new Error("THROWN!"); |
| 14 | +// }); |
| 15 | +// }); |
16 | 16 |
|
17 | | - it("should fail when the function doesn't throw", () => { |
18 | | - let err; |
19 | | - try { |
20 | | - throws(() => {}, Error); |
21 | | - } catch (e) { |
22 | | - err = e; |
23 | | - } |
| 17 | +// it("should fail when the function doesn't throw", () => { |
| 18 | +// let err; |
| 19 | +// try { |
| 20 | +// throws(() => {}, Error); |
| 21 | +// } catch (e) { |
| 22 | +// err = e; |
| 23 | +// } |
24 | 24 |
|
25 | | - expect(err instanceof Error).toBe(true); |
26 | | - }); |
27 | | -}); |
| 25 | +// expect(err instanceof Error).toBe(true); |
| 26 | +// }); |
| 27 | +// }); |
28 | 28 |
|
29 | | -describe("NodeTestHelpers.assert()", () => { |
30 | | - it("should pass when the provided value is true", () => { |
31 | | - assert(true); |
32 | | - }); |
| 29 | +// describe("NodeTestHelpers.assert()", () => { |
| 30 | +// it("should pass when the provided value is true", () => { |
| 31 | +// assert(true); |
| 32 | +// }); |
33 | 33 |
|
34 | | - it("should fail when the provided value is false", () => { |
35 | | - let err; |
36 | | - try { |
37 | | - assert(false); |
38 | | - } catch (e) { |
39 | | - err = e; |
40 | | - } |
41 | | - expect(err instanceof Error).toBe(true); |
42 | | - }); |
43 | | -}); |
| 34 | +// it("should fail when the provided value is false", () => { |
| 35 | +// let err; |
| 36 | +// try { |
| 37 | +// assert(false); |
| 38 | +// } catch (e) { |
| 39 | +// err = e; |
| 40 | +// } |
| 41 | +// expect(err instanceof Error).toBe(true); |
| 42 | +// }); |
| 43 | +// }); |
44 | 44 |
|
45 | | -describe("NodeTestHelpers.strictEqual()", () => { |
46 | | - it("should pass when the provided values are deeply equal", () => { |
47 | | - strictEqual(1, 1); |
48 | | - strictEqual("hello", "hello"); |
49 | | - const testing = { hello: "world" }; |
50 | | - const testing2 = testing; |
51 | | - testing2.hello = "bla"; |
52 | | - strictEqual(testing, testing2); |
53 | | - strictEqual(NaN, NaN); |
54 | | - strictEqual(Infinity, Infinity); |
55 | | - strictEqual(-Infinity, -Infinity); |
56 | | - strictEqual(null, null); |
57 | | - strictEqual(undefined, undefined); |
58 | | - }); |
| 45 | +// describe("NodeTestHelpers.strictEqual()", () => { |
| 46 | +// it("should pass when the provided values are deeply equal", () => { |
| 47 | +// strictEqual(1, 1); |
| 48 | +// strictEqual("hello", "hello"); |
| 49 | +// const testing = { hello: "world" }; |
| 50 | +// const testing2 = testing; |
| 51 | +// testing2.hello = "bla"; |
| 52 | +// strictEqual(testing, testing2); |
| 53 | +// strictEqual(NaN, NaN); |
| 54 | +// strictEqual(Infinity, Infinity); |
| 55 | +// strictEqual(-Infinity, -Infinity); |
| 56 | +// strictEqual(null, null); |
| 57 | +// strictEqual(undefined, undefined); |
| 58 | +// }); |
59 | 59 |
|
60 | | - it("should fail when the provided values are not deeply equal", () => { |
61 | | - let err = null; |
62 | | - try { |
63 | | - strictEqual(1, 5); |
64 | | - } catch (e) { |
65 | | - err = e; |
66 | | - } |
67 | | - expect(err instanceof Error).toBe(true); |
68 | | - err = null; |
69 | | - try { |
70 | | - strictEqual({ foo: "bar" }, { foo: "bar" }); |
71 | | - } catch (e) { |
72 | | - err = e; |
73 | | - } |
74 | | - expect(err instanceof Error).toBe(true); |
75 | | - err = null; |
76 | | - try { |
77 | | - strictEqual("1", 1); |
78 | | - } catch (e) { |
79 | | - err = e; |
80 | | - } |
81 | | - expect(err instanceof Error).toBe(true); |
82 | | - err = null; |
83 | | - const obj1 = { foo: "bar" }; |
84 | | - const obj2 = JSON.parse(JSON.stringify(obj1)); |
85 | | - try { |
86 | | - strictEqual(obj1, obj2); |
87 | | - } catch (e) { |
88 | | - err = e; |
89 | | - } |
90 | | - expect(err instanceof Error).toBe(true); |
91 | | - }); |
92 | | -}); |
| 60 | +// it("should fail when the provided values are not deeply equal", () => { |
| 61 | +// let err = null; |
| 62 | +// try { |
| 63 | +// strictEqual(1, 5); |
| 64 | +// } catch (e) { |
| 65 | +// err = e; |
| 66 | +// } |
| 67 | +// expect(err instanceof Error).toBe(true); |
| 68 | +// err = null; |
| 69 | +// try { |
| 70 | +// strictEqual({ foo: "bar" }, { foo: "bar" }); |
| 71 | +// } catch (e) { |
| 72 | +// err = e; |
| 73 | +// } |
| 74 | +// expect(err instanceof Error).toBe(true); |
| 75 | +// err = null; |
| 76 | +// try { |
| 77 | +// strictEqual("1", 1); |
| 78 | +// } catch (e) { |
| 79 | +// err = e; |
| 80 | +// } |
| 81 | +// expect(err instanceof Error).toBe(true); |
| 82 | +// err = null; |
| 83 | +// const obj1 = { foo: "bar" }; |
| 84 | +// const obj2 = JSON.parse(JSON.stringify(obj1)); |
| 85 | +// try { |
| 86 | +// strictEqual(obj1, obj2); |
| 87 | +// } catch (e) { |
| 88 | +// err = e; |
| 89 | +// } |
| 90 | +// expect(err instanceof Error).toBe(true); |
| 91 | +// }); |
| 92 | +// }); |
93 | 93 |
|
94 | | -describe("NodeTestHelpers.createCallCheckCtx", () => { |
95 | | - it("should pass when all mustCall marked callbacks have been called", (done) => { |
96 | | - const { mustCall } = createCallCheckCtx(done); |
97 | | - const fn1 = mustCall(() => {}); |
98 | | - const fn2 = mustCall(() => {}); |
99 | | - fn1(); |
100 | | - fn2(); |
101 | | - }); |
| 94 | +// describe("NodeTestHelpers.createCallCheckCtx", () => { |
| 95 | +// it("should pass when all mustCall marked callbacks have been called", (done) => { |
| 96 | +// const { mustCall } = createCallCheckCtx(done); |
| 97 | +// const fn1 = mustCall(() => {}); |
| 98 | +// const fn2 = mustCall(() => {}); |
| 99 | +// fn1(); |
| 100 | +// fn2(); |
| 101 | +// }); |
102 | 102 |
|
103 | | - it("should fail when all mustCall marked callbacks have NOT been called", (done) => { |
104 | | - const mockDone = (result) => { |
105 | | - expect(result instanceof Error).toBe(true); |
106 | | - done(); |
107 | | - }; |
108 | | - const { mustCall } = createCallCheckCtx(mockDone, 600); |
109 | | - const fn1 = mustCall(() => {}); |
110 | | - mustCall(() => {}); |
111 | | - fn1(); |
112 | | - }); |
| 103 | +// it("should fail when all mustCall marked callbacks have NOT been called", (done) => { |
| 104 | +// const mockDone = (result) => { |
| 105 | +// expect(result instanceof Error).toBe(true); |
| 106 | +// done(); |
| 107 | +// }; |
| 108 | +// const { mustCall } = createCallCheckCtx(mockDone, 600); |
| 109 | +// const fn1 = mustCall(() => {}); |
| 110 | +// mustCall(() => {}); |
| 111 | +// fn1(); |
| 112 | +// }); |
113 | 113 |
|
114 | | - it("should allow us to get the args of the wrapped callback from mustCall", (done) => { |
115 | | - const { mustCall } = createCallCheckCtx(done); |
116 | | - const fn1 = mustCall((arg1, arg2) => { |
117 | | - expect(arg1).toBe("hello"); |
118 | | - expect(arg2).toBe("world"); |
119 | | - }); |
120 | | - fn1("hello", "world"); |
121 | | - }); |
122 | | -}); |
| 114 | +// it("should allow us to get the args of the wrapped callback from mustCall", (done) => { |
| 115 | +// const { mustCall } = createCallCheckCtx(done); |
| 116 | +// const fn1 = mustCall((arg1, arg2) => { |
| 117 | +// expect(arg1).toBe("hello"); |
| 118 | +// expect(arg2).toBe("world"); |
| 119 | +// }); |
| 120 | +// fn1("hello", "world"); |
| 121 | +// }); |
| 122 | +// }); |
123 | 123 |
|
124 | | -describe("NodeTestHelpers.createDoneDotAll()", () => { |
125 | | - it("should pass when all dones have been called", (done) => { |
126 | | - const createDone = createDoneDotAll(done); |
127 | | - const done1 = createDone(600); |
128 | | - const done2 = createDone(600); |
129 | | - setTimeout(() => done1(), 300); |
130 | | - setTimeout(() => done2(), 450); |
131 | | - }); |
| 124 | +// describe("NodeTestHelpers.createDoneDotAll()", () => { |
| 125 | +// it("should pass when all dones have been called", (done) => { |
| 126 | +// const createDone = createDoneDotAll(done); |
| 127 | +// const done1 = createDone(600); |
| 128 | +// const done2 = createDone(600); |
| 129 | +// setTimeout(() => done1(), 300); |
| 130 | +// setTimeout(() => done2(), 450); |
| 131 | +// }); |
132 | 132 |
|
133 | | - it("should fail when all dones have NOT been called before timeout", (done) => { |
134 | | - const mockDone = (result) => { |
135 | | - expect(result instanceof Error).toBe(true); |
136 | | - done(); |
137 | | - }; |
138 | | - const createDone = createDoneDotAll(mockDone); |
139 | | - const done1 = createDone(400); |
140 | | - createDone(400); |
141 | | - setTimeout(() => done1(), 200); |
142 | | - }); |
| 133 | +// it("should fail when all dones have NOT been called before timeout", (done) => { |
| 134 | +// const mockDone = (result) => { |
| 135 | +// expect(result instanceof Error).toBe(true); |
| 136 | +// done(); |
| 137 | +// }; |
| 138 | +// const createDone = createDoneDotAll(mockDone); |
| 139 | +// const done1 = createDone(400); |
| 140 | +// createDone(400); |
| 141 | +// setTimeout(() => done1(), 200); |
| 142 | +// }); |
143 | 143 |
|
144 | | - it("should allow us to combine mustCall and multiple dones", (done) => { |
145 | | - const createDone = createDoneDotAll(done); |
146 | | - const { mustCall } = createCallCheckCtx(createDone(600)); |
147 | | - const done1 = createDone(600); |
148 | | - const done2 = createDone(600); |
149 | | - const fn1 = mustCall(() => {}); |
150 | | - const fn2 = mustCall(() => {}); |
151 | | - setTimeout(() => done1(), 300); |
152 | | - setTimeout(() => done2(), 450); |
153 | | - setTimeout(() => fn1(), 200); |
154 | | - setTimeout(() => fn2(), 200); |
155 | | - }); |
| 144 | +// it("should allow us to combine mustCall and multiple dones", (done) => { |
| 145 | +// const createDone = createDoneDotAll(done); |
| 146 | +// const { mustCall } = createCallCheckCtx(createDone(600)); |
| 147 | +// const done1 = createDone(600); |
| 148 | +// const done2 = createDone(600); |
| 149 | +// const fn1 = mustCall(() => {}); |
| 150 | +// const fn2 = mustCall(() => {}); |
| 151 | +// setTimeout(() => done1(), 300); |
| 152 | +// setTimeout(() => done2(), 450); |
| 153 | +// setTimeout(() => fn1(), 200); |
| 154 | +// setTimeout(() => fn2(), 200); |
| 155 | +// }); |
156 | 156 |
|
157 | | - it("should fail if a done is called with an error", (done) => { |
158 | | - const mockDone = (result) => { |
159 | | - expect(result instanceof Error).toBe(true); |
160 | | - done(); |
161 | | - }; |
162 | | - const createDone = createDoneDotAll(mockDone); |
| 157 | +// it("should fail if a done is called with an error", (done) => { |
| 158 | +// const mockDone = (result) => { |
| 159 | +// expect(result instanceof Error).toBe(true); |
| 160 | +// done(); |
| 161 | +// }; |
| 162 | +// const createDone = createDoneDotAll(mockDone); |
163 | 163 |
|
164 | | - const done1 = createDone(600); |
165 | | - const done2 = createDone(600); |
166 | | - setTimeout(() => done1(), 300); |
167 | | - setTimeout(() => done2(new Error("ERROR!")), 450); |
168 | | - }); |
169 | | -}); |
| 164 | +// const done1 = createDone(600); |
| 165 | +// const done2 = createDone(600); |
| 166 | +// setTimeout(() => done1(), 300); |
| 167 | +// setTimeout(() => done2(new Error("ERROR!")), 450); |
| 168 | +// }); |
| 169 | +// }); |
0 commit comments