如何为javascript编写qunit
我不是很喜欢昆特,但我想进入昆特。 有人能指导我为我刚刚编写的简单js脚本编写qunit测试吗?剧本很好用 这里是完整的脚本如何为javascript编写qunit,javascript,unit-testing,qunit,Javascript,Unit Testing,Qunit,我不是很喜欢昆特,但我想进入昆特。 有人能指导我为我刚刚编写的简单js脚本编写qunit测试吗?剧本很好用 这里是完整的脚本 (function ($) { My.UserCenter = My.View.extend({ cookie_name: 'my_norefresh', events: { 'click input.options': 'togglePortalRefresh' }, in
(function ($) {
My.UserCenter = My.View.extend({
cookie_name: 'my_norefresh',
events: {
'click input.options': 'togglePortalRefresh'
},
initialize: function (options) {
My.View.prototype.initialize.apply(this, arguments);
this.$el.find('[data-toggle="popover"]').popover({trigger: 'hover focus'});
if (this.getCookie() === '1') {
$('#optionOn').parent().addClass('buttongray');
$('#optionOff').parent().addClass('buttonblue');
}
else {
$('#optionOn').parent().addClass('buttonblue');
$('#optionOff').parent().addClass('buttongray');
}
},
togglePortalRefresh: function() {
var cookie_exist = this.getCookie();
if (typeof cookie_exist === 'undefined' || cookie_exist === null) {
this.setCookie();
}
else {
this.deleteCookie();
}
$('#optionOn').parent().toggleClass('buttongray buttonblue');
$('#optionOff').parent().toggleClass('buttongray buttonblue');
},
getCookie: function() {
return $.cookie(this.cookie_name);
},
setCookie: function() {
$.cookie(this.cookie_name, '1', {
expires: 9999,
path: '/'
});
},
deleteCookie: function() {
$.cookie(this.cookie_name, null, {
expires: -1,
path: '/'
});
}
});
} (My.$));
非常感谢您的帮助。我认为这是一个涉及多个问题的过于宽泛的话题,包括首先确定要测试什么,然后确定如何进行测试。我建议从开始,它涵盖了许多场景。同意,所以不是指南或教程的地方。试试这个!