filesystem.test.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Filesystem = require("../filesystem");
  4. var path = require("path");
  5. describe("filesystem", function () {
  6. var fileThatExists = path.join(__dirname, "../../package.json");
  7. var fileThatNotExists = path.join(__dirname, "../../package2.json");
  8. it("should find file that exists, sync", function () {
  9. var result = Filesystem.fileExistsSync(fileThatExists);
  10. expect(result).toBe(true);
  11. });
  12. it("should not find file that not exists, sync", function () {
  13. var result = Filesystem.fileExistsSync(fileThatNotExists);
  14. expect(result).toBe(false);
  15. });
  16. it("should find file that exists, async", function (done) {
  17. Filesystem.fileExistsAsync(fileThatExists, function (_err, result) {
  18. try {
  19. expect(result).toBe(true);
  20. done();
  21. }
  22. catch (error) {
  23. done(error);
  24. }
  25. });
  26. });
  27. it("should not find file that not exists, async", function (done) {
  28. Filesystem.fileExistsAsync(fileThatNotExists, function (_err, result) {
  29. try {
  30. expect(result).toBe(false);
  31. done();
  32. }
  33. catch (error) {
  34. done(error);
  35. }
  36. });
  37. });
  38. it("should load json, sync", function () {
  39. var result = Filesystem.readJsonFromDiskSync(fileThatExists);
  40. expect(result);
  41. expect(result.main).toBe("lib/index.js");
  42. });
  43. it("should load json, async", function (done) {
  44. Filesystem.readJsonFromDiskAsync(fileThatExists, function (_err, result) {
  45. try {
  46. expect(result).toBeTruthy();
  47. expect(result.main).toBe("lib/index.js");
  48. done();
  49. }
  50. catch (error) {
  51. done(error);
  52. }
  53. });
  54. });
  55. });
  56. //# sourceMappingURL=filesystem.test.js.map