add test cases
This commit is contained in:
parent
1d2253fdab
commit
11e71ed26b
|
@ -14,6 +14,9 @@ describe("WatchDetection", () => {
|
|||
|
||||
jest.setTimeout(10000);
|
||||
|
||||
createTestCase(100, true);
|
||||
createTestCase(10, true);
|
||||
createTestCase(600, true);
|
||||
for (let changeTimeout = 10; changeTimeout < 100; changeTimeout += 10) {
|
||||
createTestCase(changeTimeout);
|
||||
}
|
||||
|
@ -21,8 +24,10 @@ describe("WatchDetection", () => {
|
|||
createTestCase(changeTimeout);
|
||||
}
|
||||
|
||||
function createTestCase(changeTimeout) {
|
||||
describe(`time between changes ${changeTimeout}ms`, () => {
|
||||
function createTestCase(changeTimeout, invalidate) {
|
||||
describe(`time between changes ${changeTimeout}ms${
|
||||
invalidate ? " with invalidate call" : ""
|
||||
}`, () => {
|
||||
const fixturePath = path.join(
|
||||
__dirname,
|
||||
"fixtures",
|
||||
|
@ -105,7 +110,10 @@ describe("WatchDetection", () => {
|
|||
}
|
||||
|
||||
function step2() {
|
||||
onChange = null;
|
||||
onChange = () => {
|
||||
expect(compiler.modifiedFiles).not.toBe(undefined);
|
||||
expect(compiler.removedFiles).not.toBe(undefined);
|
||||
};
|
||||
|
||||
fs.writeFile(
|
||||
filePath,
|
||||
|
@ -118,8 +126,7 @@ describe("WatchDetection", () => {
|
|||
}
|
||||
|
||||
function step3() {
|
||||
onChange = null;
|
||||
|
||||
if (invalidate) watcher.invalidate();
|
||||
fs.writeFile(file2Path, "wrong", "utf-8", handleError);
|
||||
|
||||
setTimeout(step4, changeTimeout);
|
||||
|
@ -127,6 +134,8 @@ describe("WatchDetection", () => {
|
|||
|
||||
function step4() {
|
||||
onChange = () => {
|
||||
expect(compiler.modifiedFiles).not.toBe(undefined);
|
||||
expect(compiler.removedFiles).not.toBe(undefined);
|
||||
if (
|
||||
memfs
|
||||
.readFileSync("/directory/bundle.js")
|
||||
|
|
Loading…
Reference in New Issue