Sha256: 5abac98e874d4e54496402e86d388dd2ca398f31e4455609c3f1a953388a2cb1

Contents?: true

Size: 1.87 KB

Versions: 50

Compression:

Stored size: 1.87 KB

Contents

import * as Filesystem from "../filesystem";
import * as path from "path";

describe("filesystem", () => {
  const fileThatExists = path.join(__dirname, "../../package.json");
  const fileThatNotExists = path.join(__dirname, "../../package2.json");

  it("should find file that exists, sync", () => {
    const result = Filesystem.fileExistsSync(fileThatExists);
    // assert.equal(result, true);
    expect(result).toBe(true);
  });

  it("should not find file that not exists, sync", () => {
    const result = Filesystem.fileExistsSync(fileThatNotExists);
    // assert.equal(result, false);
    expect(result).toBe(false);
  });

  it("should find file that exists, async", (done) => {
    Filesystem.fileExistsAsync(fileThatExists, (_err, result) => {
      try {
        // assert.equal(result, true);
        expect(result).toBe(true);
        done();
      } catch (error) {
        done(error);
      }
    });
  });

  it("should not find file that not exists, async", (done) => {
    Filesystem.fileExistsAsync(fileThatNotExists, (_err, result) => {
      try {
        // assert.equal(result, false);
        expect(result).toBe(false);
        done();
      } catch (error) {
        done(error);
      }
    });
  });

  it("should load json, sync", () => {
    const result = Filesystem.readJsonFromDiskSync(fileThatExists);
    // assert.isOk(result);
    expect(result);
    // assert.equal(result.main, "lib/index.js");
    expect(result.main).toBe("lib/index.js");
  });

  it("should load json, async", (done) => {
    Filesystem.readJsonFromDiskAsync(fileThatExists, (_err, result) => {
      try {
        // assert.isOk(result); // Asserts that object is truthy.
        expect(result).toBeTruthy();
        // assert.equal(result.main, "lib/index.js");
        expect(result.main).toBe("lib/index.js");
        done();
      } catch (error) {
        done(error);
      }
    });
  });
});

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.59 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.58 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.57 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.56 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.55 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.54 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.53 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.52 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.51 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.50 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.49 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.48 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.47 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.46 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.45 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.44 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.43 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.42 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
immosquare-cleaner-0.1.41 node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts