Blame view

frontend/web/js/raty-2.7.0/spec/mouseover_spec.js 1.26 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
  describe('#mouseover', function() {
    beforeEach(function() {
      $.fn.raty.defaults.path = '../lib/images';
  
      this.el = Helper.create('#el');
    });
  
    afterEach(function() {
      Helper.clear();
    });
  
    it ('receives the score as int', function() {
      // given
      this.el.raty({
        mouseover: function(score) {
          $(this).data('score', score);
        }
      });
  
      var star = this.el.children('img:last');
  
      // when
      star.trigger('mouseover');
  
      // then
      expect(this.el.data('score')).toEqual(5);
    });
  
    it ('receives the mouse event', function() {
      // given
      this.el.raty({
        mouseover: function(_, evt) {
          $(this).data('evt', evt);
        }
      });
  
      var star = this.el.children('img:last');
  
      // when
      star.trigger('mouseover');
  
      // then
      expect(this.el.data('evt').type).toEqual('mouseover');
    });
  
    context('with :cancel', function() {
      it ('receives null as score', function() {
        // given
        this.el.raty({
          cancel    : true,
          mouseover : function(score) {
            $(this).data('score', score);
          }
        });
  
        var cancel = this.el.children('.raty-cancel');
  
        // when
        cancel.trigger('mouseover');
  
        // then
        expect(this.el.data('score')).toBeNull();
      });
    });
  });