« index

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

83 lines | 83 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

  require("../../lib/jasmine-promise");
  var MockFs = require("../../../fs-mock");
  var normalize = require('../../../fs').normal;
  
  describe("symbolic 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.symbolicCopy("/a/b/c.txt", "a/b/d.txt", "file")
          })
  
          // should have a link
          .then(function () {
              return mock.readLink("a/b/d.txt")
          })
          .then(function (link) {
              expect(link).toBe("c.txt");
          })
  
          // should have a canonical path
          .then(function () {
              return mock.canonical("a/b/d.txt")
          })
          .then(function (canonical) {
              expect(canonical).toBe("/a/b/c.txt");
          })
  
          // 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 non-destructive
          .then(function () {
              return mock.read("a/b/c.txt")
          })
          .then(function (content) {
              expect(content).toBe("Hello, World!");
          })
  
          // should be identified as a file
          .then(function () {
              return mock.isSymbolicLink("a/b/d.txt");
          })
          .then(function (isSymbolicLink) {
              expect(isSymbolicLink).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