Skip to content

Commit

Permalink
test: Check that Snapshot iterables have stable identities
Browse files Browse the repository at this point in the history
  • Loading branch information
gluxon committed Jul 1, 2022
1 parent 751e123 commit 7b3f4c0
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/FileSystemInfo.unittest.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,50 @@ ${details(snapshot)}`)
}
});
}

describe("stable iterables identity", () => {
const options = { timestamp: true };

/**
* @param {function((WebpackError | null)=, (Snapshot | null)=): void} callback callback function
*/
function getSnapshot(callback) {
const fs = createFs();
const fsInfo = createFsInfo(fs);
fsInfo.createSnapshot(
Date.now() + 10000,
files,
directories,
missing,
options,
callback
);
}

it("should return same iterable for getFileIterable()", done => {
getSnapshot((err, snapshot) => {
if (err) done(err);
expect(snapshot.getFileIterable()).toEqual(snapshot.getFileIterable());
done();
});
});

it("should return same iterable for getContextIterable()", done => {
getSnapshot((err, snapshot) => {
if (err) done(err);
expect(snapshot.getContextIterable()).toEqual(
snapshot.getContextIterable()
);
done();
});
});

it("should return same iterable for getMissingIterable()", done => {
getSnapshot((err, snapshot) => {
if (err) done(err);
expect(snapshot.getFileIterable()).toEqual(snapshot.getFileIterable());
done();
});
});
});
});

0 comments on commit 7b3f4c0

Please sign in to comment.