« index

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

56 lines | 56 run | 0 missing | 0 partial | 7 blocks | 7 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

  "use strict";
  
  require("../../lib/jasmine-promise");
  var Q = require("q");
  var FS = require("../../../fs");
  var Mock = require("../../../fs-mock");
  var normalize = FS.normal;
  
  describe("copyTree", function () {
      it("should copy a tree", function () {
  
          var mock = Mock({
              "a/b": {
                  "c": {
                      "d": 66,
                      "e": 99
                  }
              }
          });
  
          return Q.fcall(function () {
              return mock.copyTree("a/b", "a/f");
          })
          .then(function () {
              return Q.all([
                  mock.isDirectory("a/f"),
                  mock.exists("a/f/c"),
                  mock.isFile("a/f/c/d"),
                  mock.read("a/f/c/e")
              ])
          })
          .then(function (existence) {
              expect(existence.every(Boolean)).toBe(true);
          })
  
          .then(function () {
              return mock.listTree();
          })
          .then(function (list) {
              expect(list).toEqual([
                  ".",
                  "a",
                  normalize("a/b"),
                  normalize("a/b/c"),
                  normalize("a/b/c/d"),
                  normalize("a/b/c/e"),
                  normalize("a/f"),
                  normalize("a/f/c"),
                  normalize("a/f/c/d"),
                  normalize("a/f/c/e")
              ]);
          })
  
      });
  
  });
« index | cover.io