1 | import {checkExistsSync, MemoryFileSystem} from "../src/universal";
|
2 | import {expect} from "chai";
|
3 | import {checkExists} from "../src/user-utils";
|
4 | import {NoFeedbackEventsFileSystem} from "../src/no-feedback-events-fs";
|
5 |
|
6 | describe('user-utils', () => {
|
7 | describe('checkExistsSync', () => {
|
8 | const fs = new MemoryFileSystem('', {content: {foo: {bar: {"a.file": 'hello'}}}});
|
9 |
|
10 | it('true for existing file', () => {
|
11 | expect(checkExistsSync('file', fs, 'foo/bar/a.file')).to.eql(true);
|
12 | });
|
13 | it('true for existing dir', () => {
|
14 | expect(checkExistsSync('dir', fs, 'foo/bar')).to.eql(true);
|
15 | });
|
16 | it('false for non existing file', () => {
|
17 | expect(checkExistsSync('file', fs, 'a/foo/bar/a.file')).to.eql(false);
|
18 | });
|
19 | it('false for non existing dir', () => {
|
20 | expect(checkExistsSync('dir', fs, 'a/foo/bar')).to.eql(false);
|
21 | });
|
22 | it('false for existing file when looking for dir', () => {
|
23 | expect(checkExistsSync('dir', fs, 'foo/bar/a.file')).to.eql(false);
|
24 | });
|
25 | it('false for non existing dir when looking for file', () => {
|
26 | expect(checkExistsSync('file', fs, 'foo/bar')).to.eql(false);
|
27 | });
|
28 | });
|
29 | describe('checkExists', () => {
|
30 |
|
31 | const fs = new NoFeedbackEventsFileSystem(new MemoryFileSystem('', {content: {foo: {bar: {"a.file": 'hello'}}}}));
|
32 |
|
33 | it('true for existing file', async () => {
|
34 | expect(await checkExists('file', fs, 'foo/bar/a.file')).to.eql(true);
|
35 | });
|
36 | it('true for existing dir', async () => {
|
37 | expect(await checkExists('dir', fs, 'foo/bar')).to.eql(true);
|
38 | });
|
39 | it('false for non existing file', async () => {
|
40 | expect(await checkExists('file', fs, 'a/foo/bar/a.file')).to.eql(false);
|
41 | });
|
42 | it('false for non existing dir', async () => {
|
43 | expect(await checkExists('dir', fs, 'a/foo/bar')).to.eql(false);
|
44 | });
|
45 | it('false for existing file when looking for dir', async () => {
|
46 | expect(await checkExists('dir', fs, 'foo/bar/a.file')).to.eql(false);
|
47 | });
|
48 | it('false for non existing dir when looking for file', async () => {
|
49 | expect(await checkExists('file', fs, 'foo/bar')).to.eql(false);
|
50 | });
|
51 | });
|
52 | });
|