Skip to content

Commit 882484f

Browse files
Attempt to produce a failing spec on Linux
1 parent 405ce7d commit 882484f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

spec/pathwatcher-spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,29 @@ describe('PathWatcher', () => {
1919
await wait(100);
2020
});
2121

22+
describe('when a watched file is replaced via atomic save', () => {
23+
it('fires the callback with a change event', async () => {
24+
let eventType;
25+
let eventPath;
26+
27+
PathWatcher.watch(tempFile, (type, path) => {
28+
eventType = type;
29+
eventPath = path;
30+
});
31+
32+
await wait(20);
33+
34+
let tempFileCopy = path.join(tempDir, 'file-copy');
35+
fs.writeFileSync(tempFileCopy, 'atomic save content');
36+
fs.renameSync(tempFileCopy, tempFile);
37+
38+
await condition(() => !!eventType);
39+
40+
expect(eventType).toBe('change');
41+
expect(eventPath).toBe('');
42+
});
43+
});
44+
2245
describe('getWatchedPaths', () => {
2346
it('returns an array of all watched paths', () => {
2447
let realTempFilePath = fs.realpathSync(tempFile);

0 commit comments

Comments
 (0)