34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
import {Host} from "../../dist";
|
|
import {resolve} from "path";
|
|
|
|
test('host.basic', async ()=>{
|
|
let host = new Host({workingDirectory: __dirname});
|
|
|
|
await host.remove("basic", {recursive: true});// Make sure dir is removed and we have clean start (could have the user pass a force flag here..
|
|
let testHost = await host.cwd('basic');
|
|
|
|
await testHost.write('test-file.out', "I am the first basic test-file!");
|
|
await testHost.write('dist/test-file.txt', "I am a very basic test-file yo!");
|
|
await testHost.write('dist/other/another-file.txt', "I serve to fill a tree of files");
|
|
await testHost.write('dist/other/more-files.out', "I also serve to fill a tree of files!");
|
|
|
|
let tree = await testHost.traverse();
|
|
expect(tree.length).toBe(6); // Expecting 6 results, because it should include the directories as well
|
|
|
|
let txtFiles = await testHost.glob('**/*.txt');
|
|
expect(txtFiles.length).toBe(2);
|
|
|
|
let outFiles = await testHost.glob('**/*.out');
|
|
expect(outFiles.length).toBe(2);
|
|
|
|
|
|
let subHost = testHost.from('dist/other');
|
|
let subOutFiles = await subHost.glob('../../**/*.out');
|
|
expect(subOutFiles.length).toBe(2);
|
|
|
|
|
|
/** @type {module:fs.Stats} */
|
|
let stats = await host.stat('basic/test-file.out');
|
|
expect(stats.isFile()).toBe(true);
|
|
});
|