filesystem.test.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // assert.equal(result, true);
  11. expect(result).toBe(true);
  12. });
  13. it("should not find file that not exists, sync", function () {
  14. var result = Filesystem.fileExistsSync(fileThatNotExists);
  15. // assert.equal(result, false);
  16. expect(result).toBe(false);
  17. });
  18. it("should find file that exists, async", function (done) {
  19. Filesystem.fileExistsAsync(fileThatExists, function (_err, result) {
  20. try {
  21. // assert.equal(result, true);
  22. expect(result).toBe(true);
  23. done();
  24. }
  25. catch (error) {
  26. done(error);
  27. }
  28. });
  29. });
  30. it("should not find file that not exists, async", function (done) {
  31. Filesystem.fileExistsAsync(fileThatNotExists, function (_err, result) {
  32. try {
  33. // assert.equal(result, false);
  34. expect(result).toBe(false);
  35. done();
  36. }
  37. catch (error) {
  38. done(error);
  39. }
  40. });
  41. });
  42. it("should load json, sync", function () {
  43. var result = Filesystem.readJsonFromDiskSync(fileThatExists);
  44. // assert.isOk(result);
  45. expect(result);
  46. // assert.equal(result.main, "lib/index.js");
  47. expect(result.main).toBe("lib/index.js");
  48. });
  49. it("should load json, async", function (done) {
  50. Filesystem.readJsonFromDiskAsync(fileThatExists, function (_err, result) {
  51. try {
  52. // assert.isOk(result); // Asserts that object is truthy.
  53. expect(result).toBeTruthy();
  54. // assert.equal(result.main, "lib/index.js");
  55. expect(result.main).toBe("lib/index.js");
  56. done();
  57. }
  58. catch (error) {
  59. done(error);
  60. }
  61. });
  62. });
  63. });
  64. //# sourceMappingURL=filesystem.test.js.map