« index
Coverage for /Users/kris/q-io/spec/fs/mock/make-tree-spec.js : 100%
108 lines |
108 run |
0 missing |
0 partial |
18 blocks |
18 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | "use strict"; require("../../lib/jasmine-promise"); var Q = require("q"); var FS = require("../../../fs"); var Mock = require("../../../fs-mock"); var normalize = FS.normal; describe("makeTree", function () { it("should make a branch of a tree", function () { var mock = Mock({ "a": {} }); return Q.fcall(function () { return mock.makeTree("a/b/c"); }) .then(function () { return mock.listTree(); }) .then(function (list) { expect(list).toEqual([ ".", "a", normalize("a/b"), normalize("a/b/c") ]); }) .then(function () { return mock.exists("a/b/c") }) .then(function (exists) { expect(exists).toBe(true); }) .then(function () { return mock.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 () { var mock = Mock({ "a/b": {} }); return Q.fcall(function () { return mock.makeTree("a/b/c/d"); }) .then(function () { return mock.listTree(); }) .then(function (list) { expect(list).toEqual([ ".", "a", normalize("a/b"), normalize("a/b/c"), normalize("a/b/c/d") ]); }) }); it("should make an absolute tree from a subdirectory", function () { var mock = Mock({ "a/b": { "c": { "d.ext": 66 } } }, "/a/b"); return Q.fcall(function () { return mock.makeTree("/a/b/c/x/y/z"); }) .then(function () { return Q.all([ mock.isDirectory("a/b/c/x"), mock.isDirectory("a/b/c/x/y"), mock.isDirectory("a/b/c/x/y/z") ]); }) .then(function () { return mock.listTree("/"); }) .then(function (list) { expect(list).toEqual([ "/", "/a", "/a/b", "/a/b/c", "/a/b/c/d.ext", "/a/b/c/x", "/a/b/c/x/y", "/a/b/c/x/y/z" ]); }); }); }); |