UNPKG

raty-js

Version:

Raty - A Star Rating Plugin

66 lines (51 loc) 1.25 kB
describe('#mouseover', function() { beforeEach(function() { $.raty.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.result = score; } }); var star = this.el.children('img:last'); // when star.trigger('mouseover'); // then expect(this.el[0].result).toEqual(5); }); it ('receives the mouse event', function() { // given this.el.raty({ mouseover: function(_, evt) { this.result = evt; } }); var star = this.el.children('img:last'); // when star.trigger('mouseover'); // then expect(this.el[0].result.type).toEqual('mouseover'); }); context('with :cancel', function() { it ('receives null as score', function() { // given this.el.raty({ cancelButton: true, mouseover: function(score) { this.result = score; } }); var cancel = this.el.children('.raty-cancel'); // when cancel.trigger('mouseover'); // then expect(this.el[0].result).toBeNull(); }); }); });