« index

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

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

  require("../../lib/jasmine-promise");
  var MockFs = require("../../../fs-mock");
  var normalize = require('../../../fs').normal;
  
  describe("link", function () {
      it("should", function () {
          var mock = MockFs();
  
          // make some content
          return mock.makeTree("a/b")
          .then(function () {
              return mock.write("a/b/c.txt", "Hello, World!")
          })
  
          // verify content
          .then(function () {
              return mock.read("a/b/c.txt")
          })
          .then(function (content) {
              expect(content).toBe("Hello, World!");
          })
  
          // link it
          .then(function () {
              return mock.link("a/b/c.txt", "a/b/d.txt")
          })
  
          // should be non-destructive
          .then(function () {
              return mock.read("a/b/c.txt")
          })
          .then(function (content) {
              expect(content).toBe("Hello, World!");
          })
  
          // should be listed
          .then(function () {
              return mock.listTree()
          })
          .then(function (content) {
              expect(content).toEqual([
                  ".",
                  "a",
                  normalize("a/b"),
                  normalize("a/b/c.txt"),
                  normalize("a/b/d.txt")
              ])
          })
  
          // should be identified as a file
          .then(function () {
              return mock.isFile("a/b/d.txt");
          })
          .then(function (isFile) {
              expect(isFile).toBe(true);
          })
  
          // should have the same content
          .then(function () {
              return mock.read("a/b/d.txt");
          })
          .then(function (content) {
              expect(content).toBe("Hello, World!");
          });
  
      });
  });
« index | cover.io