qunit

Does qunit-reporter-junit generate junit compatible xml?

你。 提交于 2019-12-29 08:06:13
问题 I just used qunit-reporter-junit to generate the following XML: <?xml version="1.0" encoding="UTF-8"?> <testsuites name="http://w188823.example.com:9001/test/workflow.cloning?out=xml" hostname="localhost" tests="19" failures="2" errors="0" time="0.357" timestamp="2013-07-16T19:52:00Z"> <testsuite id="0" name="workflow.cloning.test" hostname="localhost" tests="4" failures="0" errors="0" time="0.002" timestamp="2013-07-16T19:52:00Z"> <testcase name="has schedule departure date predicate" tests=

application route's model hook not triggering in qunit integration test

南楼画角 提交于 2019-12-25 06:58:16
问题 I have a route that looks like this: App.ApplicationRoute = Ember.Route.extend({ model: function() { console.log("caching books"); this.store.find('books'); } }); When I run it locally I see the "caching books" message in the console. But when I run it in qunit the message never shows up. Why does the application route's model hook not fire in qunit? Here's my qunit integration test: module('Ember.js Library', { setup: function() { Ember.run(App, App.advanceReadiness); }, teardown: function()

QUnit testing synchronous ajax calls

只谈情不闲聊 提交于 2019-12-25 03:22:45
问题 Can somebody please tell me whether we need to use asyncTest() to test the synchronous ajax calls or test() can be used without start() and stop(). Consider this: var Class= function () { var init = function () { amplify.request.define('students', 'ajax', { url: '/methods/GetStudentsList', dataType: 'json', type: 'GET', async:false }); }; Students = function (branch, callback) { init(); return amplify.request("students", { branchID: branch }, callback.success, callback.error ); }; return {

QUnit for javascript Testing on events

我与影子孤独终老i 提交于 2019-12-24 17:57:34
问题 Im really new to javascript testing. I'm able to test all other functions of qunit. But couldn't figure out how to use qunit to test event handler functionalities. I tried the below after seeing a sample in jquery event.js test suite for trigger, bind & delegate functions. test('Event Handling', function () { var hai = function() { console.log('Clicked'); ok(true, 'click event triggered'); }; eventLib.addEvent(document.getElementById('qunit-header'), 'click', hai); $('#qunit-header').trigger(

Events Failing To Trigger In QUnit Tests

徘徊边缘 提交于 2019-12-24 13:26:34
问题 I'm new to QUnit. I'm using jQuery (tested with 1.4.2 and 1.5.1) and the latest QUnit. I can trigger events just fine in a single test, but any test afterwards fails. Here's a simplified repro: // code under test - "#Test1" is just an empty div $(document).ready(function() { $('#Test1').mouseenter(function(e) { console.log('ENTER');}); $('#Test1').mouseleave(function(e) { console.log('LEAVE');}); }); // tests test('enter', function() { $('#Test1').mouseenter(); }); test('leave', function() {

How to test an Ember model's computed property that has relations dependencies?

与世无争的帅哥 提交于 2019-12-24 10:40:04
问题 I'm writing Qunit tests to test An Ember model, but having a hard time testing computed properties that have a relation dependency (the computed property triggers another model's computed property). The model that am testing (CoffeeScript): Customer = DS.Model.extend firstName: DS.attr('string') lastName: DS.attr('string') phones: DS.attr('embedded-list') phone: (-> @get('phones.firstObject.number') ).property('phones.firstObject.number') fullName: (-> [@get('lastName'), @get('firstName')]

Correct use of QUnit throw() assertion?

醉酒当歌 提交于 2019-12-24 10:30:47
问题 Using QUinit's throw() assertion I want to test that an error is thrown and the error message. I have the following function: /** * Error function for Node. * @param {String} msg Error message. */ function NodeError (msg) { var that = this /** * Attribute for message. * @type {String} */ this.msg = msg /** * Function rendering NodeError as a string. * @return {String} String representation of NodeError. */ this.toString = function () { return that.msg } } /** * Node object. TODO Fill out. *

qunit test error with equal and deepEqual

浪尽此生 提交于 2019-12-24 07:03:53
问题 I'm Trying to understand qunit testing Why is this test failing? If I compare every property, are the same ... test("Get model equal", function () { function getModel() { function myModel() { this.name = ""; this.address = ""; this.phone = ""; } return new myModel(); } var model1 = getModel(); var model2 = getModel(); equal(model1, model2); }); test("Get model deepEqual", function () { function getModel() { function myModel() { this.name = ""; this.address = ""; this.phone = ""; } return new

How can I stub methods attached to the 'this' object using Sinon.js?

旧街凉风 提交于 2019-12-24 01:14:27
问题 I'm attempting to test the 'onInit' function attached below: function (jQuery, Controller, JSONModel) { "use strict"; var controls; var mainController = Controller.extend("tool.controller.Main", { onInit: function(oEvent) { var inputModel = new JSONModel("./model/inputs.json"); var productsModel = new JSONModel("./model/products.json"); this.getView().setModel(inputModel, "inputModel"); this.getView().setModel(productsModel); controls = viewControls.main.apply(this); }, ... Objective For this

Testing if JS method throws RangeError with QUnit

风流意气都作罢 提交于 2019-12-23 23:12:06
问题 I made some Javascript unit tests with QUnit library, then I want to test if method throws RangeError. It has be done in this way: QUnit.test("Resolve slide animation from left", function( assert ) { var myOwnCreator = new MyOwnCreator(); assert.equal(myOwnCreator.resolveAnimationType("slideSide", "show", "left"), "slide-left-in"); assert.equal(myOwnCreator.resolveAnimationType("slideSide", "hide", "left"), "slide-left-out"); assert.throws(myOwnCreator.resolveAnimationType("slideSide", "hide"