« index

Coverage for /Users/kris/q-io/spec/fs/make-tree-spec.js : 100%

85 lines | 85 run | 0 missing | 0 partial | 19 blocks | 19 blocks run | 0 blocks missing

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

  "use strict";
  
  require("../lib/jasmine-promise");
  var Q = require("q");
  var FS = require("../../fs");
  var _n = FS.normal;
  
  describe("makeTree", function () {
      it("should make a branch of a tree", function () {
  
          return Q.fcall(function () {
              return FS.makeTree("a/b/c");
          })
  
          .then(function () {
              return FS.listTree("a");
          })
          .then(function (list) {
              expect(list).toEqual([
                  "a",
                  _n("a/b"),
                  _n("a/b/c")
              ]);
          })
  
          .then(function () {
              return FS.exists("a/b/c");
          })
          .then(function (exists) {
              expect(exists).toBe(true);
          })
  
          .then(function () {
              return FS.isDirectory("a/b/c");
          })
          .then(function (isDirectory) {
              expect(isDirectory).toBe(true);
          })
  
      });
  
      it("should make a branch of a tree even if some of it already exists", function () {
  
          return Q.fcall(function () {
              return FS.makeTree("a/b/c/d");
          })
  
          .then(function () {
              return FS.listTree("a");
          })
          .then(function (list) {
              expect(list).toEqual([
                  "a",
                  _n("a/b"),
                  _n("a/b/c"),
                  _n("a/b/c/d")
              ]);
          })
          .then(function () {
              return FS.removeTree("a");
          })
      });
  
      it("should make branch from an absolute path", function () {
  
          return Q.fcall(function () {
              return FS.makeTree(FS.absolute("a/b/c/d"));
          })
  
          .then(function () {
              return FS.listTree("a");
          })
          .then(function (list) {
              expect(list).toEqual([
                  "a",
                  _n("a/b"),
                  _n("a/b/c"),
                  _n("a/b/c/d")
              ]);
          })
          .then(function () {
              return FS.removeTree("a");
          })
      });
  });
« index | cover.io