-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20138f4
commit 9e1f55c
Showing
11 changed files
with
2,491 additions
and
141 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
file 1 content |
Empty file.
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 @@ | ||
file 2 content |
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,44 @@ | ||
import fetch from 'node-fetch'; | ||
|
||
import { UserOptions } from 'src/plugin/Options'; | ||
import FsServer from '../../../src/plugin/server'; | ||
import { resolveOptions } from '../../../src/plugin/Options'; | ||
// import fs from '../../src/abstraction'; | ||
|
||
let server: FsServer; | ||
|
||
beforeAll(() => { | ||
const options: UserOptions = { | ||
rootDir: '__tests__/assets', | ||
}; | ||
server = new FsServer(resolveOptions(options)); | ||
server.start(true); | ||
}); | ||
|
||
afterAll((done) => { | ||
server.stop(); | ||
done(); | ||
}); | ||
|
||
describe('readdir request of __tests__/assets', () => { | ||
it('should return the correct file tree', async () => { | ||
const response = await fetch('http://localhost:7070?command=readdir'); | ||
const data = await response.json() as string[]; | ||
expect(response.status).toEqual(200); | ||
expect(data).toContain('file'); | ||
expect(data).toContain('file2'); | ||
expect(data).not.toContain('notfile'); | ||
}); | ||
|
||
it('should return correct file tree when ?withFileTypes=true', async () => { | ||
const response = await fetch('http://localhost:7070?command=readdir&withFileTypes=true'); | ||
const data = await response.json() as { name: string; dir: boolean }[]; | ||
expect(response.status).toEqual(200); | ||
expect(data).toEqual(expect.arrayContaining([ | ||
{ name: 'file', dir: false }, | ||
{ name: 'directory', dir: true }, | ||
])); | ||
}); | ||
}); | ||
|
||
export default {}; |
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,8 @@ | ||
export default { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.ts?$': 'ts-jest', | ||
}, | ||
transformIgnorePatterns: ['<rootDir>/node_modules/'], | ||
}; |
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
Oops, something went wrong.