aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@kwsites/file-exists/dist/test/exists.spec.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-04-17 17:37:10 +0200
committerMinteck <contact@minteck.org>2022-04-17 17:37:10 +0200
commit4081c2036a5af21519095da1b8b99c507b0fba93 (patch)
treefc95894e74c84d4d34c0d761837e8d6175829dd7 /node_modules/@kwsites/file-exists/dist/test/exists.spec.js
parent637ca7ba746c0241aaec79b79349d5dac4ec7408 (diff)
downloadtwilight-4081c2036a5af21519095da1b8b99c507b0fba93.tar.gz
twilight-4081c2036a5af21519095da1b8b99c507b0fba93.tar.bz2
twilight-4081c2036a5af21519095da1b8b99c507b0fba93.zip
Deprecation
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.js77
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