-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(core): add test for exists and fix test in windows
- Loading branch information
1 parent
67bff3b
commit 737ea43
Showing
5 changed files
with
52 additions
and
4 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
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,30 @@ | ||
import { DocgeniNodeJsAsyncHost } from './node-host'; | ||
import { normalize, virtualFs } from '@angular-devkit/core'; | ||
import { NodeJsAsyncHost } from '@angular-devkit/core/node'; | ||
import fs from 'fs'; | ||
import temp from 'temp'; | ||
|
||
describe('DocgeniNodeJsAsyncHost', () => { | ||
let root: string; | ||
let host: virtualFs.Host<fs.Stats>; | ||
|
||
beforeEach(() => { | ||
root = temp.mkdirSync('core-node-spec-'); | ||
host = new virtualFs.ScopedHost(new DocgeniNodeJsAsyncHost(), normalize(root)); | ||
}); | ||
|
||
afterEach(done => | ||
host | ||
.delete(normalize('/')) | ||
.toPromise() | ||
.then(done, done.fail) | ||
); | ||
|
||
it('should get correct result for exists', async () => { | ||
let isExists = await host.exists(normalize('not-found')).toPromise(); | ||
expect(isExists).toBe(false); | ||
await host.write(normalize('not-found'), virtualFs.stringToFileBuffer('content')).toPromise(); | ||
isExists = await host.exists(normalize('not-found')).toPromise(); | ||
expect(isExists).toBe(true); | ||
}); | ||
}); |
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