web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

  1. import { assert } from "chai";
  2. import * as Filesystem from "../src/filesystem";
  3. import * as path from "path";
  4. describe("filesystem", () => {
  5. const fileThatExists = path.join(__dirname, "../package.json");
  6. const fileThatNotExists = path.join(__dirname, "../package2.json");
  7. it("should find file that exists, sync", () => {
  8. const result = Filesystem.fileExistsSync(fileThatExists);
  9. assert.equal(result, true);
  10. });
  11. it("should not find file that not exists, sync", () => {
  12. const result = Filesystem.fileExistsSync(fileThatNotExists);
  13. assert.equal(result, false);
  14. });
  15. it("should find file that exists, async", done => {
  16. Filesystem.fileExistsAsync(fileThatExists, (_err, result) => {
  17. assert.equal(result, true);
  18. done();
  19. });
  20. });
  21. it("should not find file that not exists, async", done => {
  22. Filesystem.fileExistsAsync(fileThatNotExists, (_err, result) => {
  23. assert.equal(result, false);
  24. done();
  25. });
  26. });
  27. it("should load json, sync", () => {
  28. const result = Filesystem.readJsonFromDiskSync(fileThatExists);
  29. assert.isOk(result);
  30. assert.equal(result.main, "lib/index.js");
  31. });
  32. it("should load json, async", done => {
  33. Filesystem.readJsonFromDiskAsync(fileThatExists, (_err, result) => {
  34. assert.isOk(result);
  35. assert.equal(result.main, "lib/index.js");
  36. done();
  37. });
  38. });
  39. });