Blame view

frontend/web/js/raty-2.7.0/spec/path_spec.js 2.08 KB
c7f222e2   Artem   first
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
  describe('#path', function() {
    beforeEach(function() {
      $.fn.raty.defaults.path = '../lib/images';
  
      this.el = Helper.create('#el');
    });
  
    afterEach(function() {
      Helper.clear();
    });
  
    it ('changes the path', function() {
      // given
  
      // when
      this.el.raty({ path: '../demo/images' });
  
      // then
      expect(this.el.children('img')).toHaveAttr('src', '../demo/images/star-off.png');
    });
  
    context('without slash on the final', function() {
      it ('receives the slash', function() {
        // given
  
        // when
        this.el.raty({ path: '../demo/images' });
  
        // then
        expect(this.el[0].opt.path).toEqual('../demo/images/');
      });
    });
  
    context('with slash on the final', function() {
      it ('is keeped', function() {
        // given
  
        // when
        this.el.raty({ path: '../demo/images/' });
  
        // then
        expect(this.el[0].opt.path).toEqual('../demo/images/');
      });
    });
  
    context('as null', function() {
      it ('replace to an empty string', function() {
        // given
  
        // when
        this.el.raty({ path: null });
  
        // then
        expect(this.el.children('img')).toHaveAttr('src', 'star-off.png');
      });
    });
  
    context('as undefined', function() {
      beforeEach(function() {
        $.fn.raty.defaults.path = undefined;
      });
  
      it ('replace to an empty string', function() {
        // given
  
        // when
        this.el.raty();
  
        // then
        expect(this.el.children('img')).toHaveAttr('src', 'star-off.png');
      });
    });
  
    context('with :cancel', function() {
      it ('changes the path', function() {
        // given
  
        // when
        this.el.raty({ cancel: true, path: '../demo/images' });
  
        // then
        expect(this.el.children('.raty-cancel')).toHaveAttr('src', '../demo/images/cancel-off.png');
      });
    });
  
    context('with :iconRange', function() {
      it ('changes the path', function() {
        // given
  
        // when
        this.el.raty({ iconRange: [{ range: 1 }], path: '../demo/images' });
  
        // then
        expect(this.el.children('img')).toHaveAttr('src', '../demo/images/star-off.png');
      });
    });
  });