source: frontend/node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.9 KB
Line 
1import * as Filesystem from "../filesystem";
2import * as path from "path";
3
4describe("filesystem", () => {
5 const fileThatExists = path.join(__dirname, "../../package.json");
6 const fileThatNotExists = path.join(__dirname, "../../package2.json");
7
8 it("should find file that exists, sync", () => {
9 const result = Filesystem.fileExistsSync(fileThatExists);
10 // assert.equal(result, true);
11 expect(result).toBe(true);
12 });
13
14 it("should not find file that not exists, sync", () => {
15 const result = Filesystem.fileExistsSync(fileThatNotExists);
16 // assert.equal(result, false);
17 expect(result).toBe(false);
18 });
19
20 it("should find file that exists, async", (done) => {
21 Filesystem.fileExistsAsync(fileThatExists, (_err, result) => {
22 try {
23 // assert.equal(result, true);
24 expect(result).toBe(true);
25 done();
26 } catch (error) {
27 done(error);
28 }
29 });
30 });
31
32 it("should not find file that not exists, async", (done) => {
33 Filesystem.fileExistsAsync(fileThatNotExists, (_err, result) => {
34 try {
35 // assert.equal(result, false);
36 expect(result).toBe(false);
37 done();
38 } catch (error) {
39 done(error);
40 }
41 });
42 });
43
44 it("should load json, sync", () => {
45 const result = Filesystem.readJsonFromDiskSync(fileThatExists);
46 // assert.isOk(result);
47 expect(result);
48 // assert.equal(result.main, "lib/index.js");
49 expect(result.main).toBe("lib/index.js");
50 });
51
52 it("should load json, async", (done) => {
53 Filesystem.readJsonFromDiskAsync(fileThatExists, (_err, result) => {
54 try {
55 // assert.isOk(result); // Asserts that object is truthy.
56 expect(result).toBeTruthy();
57 // assert.equal(result.main, "lib/index.js");
58 expect(result.main).toBe("lib/index.js");
59 done();
60 } catch (error) {
61 done(error);
62 }
63 });
64 });
65});
Note: See TracBrowser for help on using the repository browser.