-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make watcher a child of the fs package (#412)
* refactor: make watcher a child of the fs package * test: add unit tests for fs/watcher * fix: use proper conditional in scripts/circle/install.sh * test: do not test watcher against watchman in appveyor * fix: cd back into build directory after installing watchman * fix: use -d to determine if watch is a directory in scrits/circle/install.sh
- Loading branch information
1 parent
20480fa
commit a4d9952
Showing
10 changed files
with
170 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ machine: | |
dependencies: | ||
override: | ||
- bash -e scripts/circle/install.sh | ||
cache_directories: | ||
- /home/ubuntu/watchman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// @flow | ||
import { join as joinPath } from 'path'; | ||
|
||
import { expect } from 'chai'; | ||
import { it, describe, after, before } from 'mocha'; | ||
|
||
import Watcher from '../watcher'; | ||
import { APPVEYOR } from '../../../constants'; | ||
|
||
import { rmrf, mkdirRec, writeFile } from '../index'; | ||
|
||
describe('module "fs"', () => { | ||
const tmpDirPath = joinPath('tmp', `lux-${Date.now()}`); | ||
const tmpAppPath = joinPath(tmpDirPath, 'app'); | ||
|
||
before(async () => { | ||
await mkdirRec(tmpAppPath); | ||
}); | ||
|
||
after(async () => { | ||
await rmrf(tmpDirPath); | ||
}); | ||
|
||
describe('class Watcher', () => { | ||
if (!APPVEYOR) { | ||
describe('- client Watchman', () => { | ||
let subject; | ||
|
||
before(async () => { | ||
subject = await new Watcher(tmpDirPath); | ||
}); | ||
|
||
describe('event "change"', () => { | ||
it('is called when a file is modified', async () => { | ||
subject.once('change', files => { | ||
expect(files).to.be.an('array'); | ||
}); | ||
|
||
await writeFile(joinPath(tmpAppPath, 'index.js'), ''); | ||
}); | ||
}); | ||
|
||
describe('#destroy()', () => { | ||
it('does not throw an error', () => { | ||
expect(() => subject.destroy()).to.not.throw(Error); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
describe('- client FSWatcher', () => { | ||
let subject; | ||
|
||
before(async () => { | ||
subject = await new Watcher(tmpDirPath, false); | ||
}); | ||
|
||
describe('event "change"', () => { | ||
it('is called when a file is modified', async () => { | ||
subject.once('change', files => { | ||
expect(files).to.be.an('array'); | ||
}); | ||
|
||
await writeFile(joinPath(tmpAppPath, 'index.js'), ''); | ||
}); | ||
}); | ||
|
||
describe('#destroy()', () => { | ||
it('does not throw an error', () => { | ||
expect(() => subject.destroy()).to.not.throw(Error); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.