Skip to content

Commit 65c90cd

Browse files
committed
wip add t.mock.module example
1 parent 7d5c268 commit 65c90cd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { describe, test, mock, before } from "node:test";
2+
import assert from "node:assert/strict";
3+
4+
let Model;
5+
/**
6+
* mock.module() was added in 22.3.0
7+
*/
8+
const isNode22Point3OrLower = (() => {
9+
const [major, minor, _patch] = process.versions.node.split(".");
10+
return !(parseInt(major, 10) >= 22 && parseInt(minor, 10) >= 3);
11+
})();
12+
describe('Class extends Mock - native', {skip: isNode22Point3OrLower }, () => {
13+
test("It should not throw when passed a model containing an empty list of meetings", async () => {
14+
mock.module('sequelize', {
15+
namedExports: {
16+
Model: class { }
17+
}
18+
});
19+
20+
const { default: _model } = await import(`./02.04-model.js?ts=${Date.now()}`);
21+
Model = _model;
22+
23+
const model = new Model();
24+
model.meetings = [];
25+
assert.doesNotThrow(model.isAvailable.bind(model, new Date(Date.now())));
26+
});
27+
28+
test("It should not throw when passed a model containing an empty list of meetings", () => {
29+
const model = Object.assign(new Model(), {
30+
meetings: [],
31+
});
32+
assert.doesNotThrow(model.isAvailable.bind(model, new Date(Date.now())));
33+
});
34+
35+
})

0 commit comments

Comments
 (0)