Blame view

frontend/web/js/raty-2.7.0/spec/fn_set_spec.js 1.49 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
  describe('#set', function() {
    beforeEach(function() {
      $.fn.raty.defaults.path = '../lib/images';
  
      this.el = Helper.create('#el');
    });
  
    afterEach(function() {
      Helper.clear();
    });
  
    it ('is chainable', function() {
      // given
      this.el.raty();
  
      // when
      var ref = this.el.raty('set', {});
  
      // then
      expect(ref).toBe(this.el);
    });
  
    it ('changes the declared options', function() {
      // given
      this.el.raty();
  
      // when
      var ref = this.el.raty('set', { scoreName: 'other' });
  
      // then
      expect(ref.children('input')).toHaveAttr('name', 'other');
    });
  
    it ('keeps the other options', function() {
      // given
      this.el.raty({ number: 6 });
  
      // when
      var ref = this.el.raty('set', { scoreName: 'other' });
  
      // then
      expect(ref.children('img').length).toEqual(6);
    });
  
    context('with external bind on wrapper', function() {
      it ('is kept', function() {
        // given
        this.el.on('click', function() {
          $(this).data('trigged', true);
        }).raty();
  
        this.el.raty('set', {});
  
        // when
        this.el.trigger('click');
  
        // then
        expect(this.el.data('trigged')).toBeTruthy();
      });
    });
  
    context('when :readOnly by function', function() {
      it ('is removes the readonly data info', function() {
        // given
        this.el.raty().raty('readOnly', true);
  
        // when
        var ref = this.el.raty('set', { readOnly: false });
  
        // then
        expect(this.el).not.toHaveData('readonly');
      });
    });
  });