diff options
author | Scoots Dash <contact@minteck.org> | 2022-04-23 14:12:30 +0000 |
---|---|---|
committer | Scoots Dash <contact@minteck.org> | 2022-04-23 14:12:30 +0000 |
commit | a927497b43cbe1438f3d7478932f3f7d03ea347c (patch) | |
tree | 0a3c88978b4294fb30afad58daa86c46fbedc2f6 /node_modules/@kwsites/file-exists/dist/test/exists.spec.js | |
parent | ba5fa694351774f2684c1aefdc215da5c6f39ba6 (diff) | |
parent | f0db5bbbcd623812a391862d217519afafe197c6 (diff) | |
download | twilight-trunk.tar.gz twilight-trunk.tar.bz2 twilight-trunk.zip |
Disable the Twilight Package Manager
See merge request minteck/twilight!1
Diffstat (limited to 'node_modules/@kwsites/file-exists/dist/test/exists.spec.js')
-rw-r--r-- | node_modules/@kwsites/file-exists/dist/test/exists.spec.js | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/node_modules/@kwsites/file-exists/dist/test/exists.spec.js b/node_modules/@kwsites/file-exists/dist/test/exists.spec.js deleted file mode 100644 index a36b549..0000000 --- a/node_modules/@kwsites/file-exists/dist/test/exists.spec.js +++ /dev/null @@ -1,77 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -jest.mock('fs'); -//@ts-ignore -const fs_1 = require("fs"); -const src_1 = require("../src"); -describe(`exists`, () => { - let statSync; - let statSyncMock; - let path; - beforeEach(() => { - path = `./path/${Math.random()}`; - fs_1.addStatSyncMock(statSyncMock = jest.fn(() => statSync())); - }); - afterEach(() => { - fs_1.assertMocksUsed(); - statSync = statSyncMock = undefined; - }); - describe('known errors', () => { - beforeEach(() => givenStatSyncThrows({ code: 'ENOENT' })); - it('with type', () => { - expect(src_1.exists(path, src_1.READABLE)).toBe(false); - }); - it('with type omitted', () => { - expect(src_1.exists(path)).toBe(false); - }); - }); - describe('unknown errors', () => { - let err; - beforeEach(() => err = givenStatSyncThrows(new Error('something'))); - it('with type', () => { - expect(() => src_1.exists(path, src_1.READABLE)).toThrow(err); - }); - it('with type omitted', () => { - expect(() => src_1.exists(path)).toThrow(err); - }); - }); - describe('path is a file', () => { - beforeEach(() => givenStatSyncIsA('file')); - existsReturns(true, false, true); - }); - describe('path is a folder', () => { - beforeEach(() => givenStatSyncIsA('folder')); - existsReturns(false, true, true); - }); - describe('path is unknown', () => { - beforeEach(() => givenStatSyncIsA('unknown')); - existsReturns(false, false, false); - }); - function existsReturns(file, folder, readable) { - it('when searching for a file', () => { - expect(src_1.exists(path, src_1.FILE)).toBe(file); - }); - it('when searching for a folder', () => { - expect(src_1.exists(path, src_1.FOLDER)).toBe(folder); - }); - it('when searching for either', () => { - expect(src_1.exists(path, src_1.READABLE)).toBe(readable); - }); - it('when searching without a type', () => { - expect(src_1.exists(path)).toBe(readable); - }); - } - function givenStatSyncThrows(err) { - statSync = () => { throw err; }; - return err; - } - function givenStatSyncIsA(type) { - const mockStat = { - isFile() { return type === 'file'; }, - isDirectory() { return type === 'folder'; }, - }; - statSync = () => mockStat; - return mockStat; - } -}); -//# sourceMappingURL=exists.spec.js.map
\ No newline at end of file |