ember-cli-test-helpers
Advanced tools
Comparing version 0.1.4 to 0.2.0
import Ember from "ember"; | ||
import { assert } from "qunit"; | ||
var assertElement = function(selector, type, count) { | ||
var element = find(selector); | ||
equal(element.length, count || 1, "element with selector '" + selector + "' not found"); | ||
equal(element.attr("type"), type); | ||
assert.equal(element.length, count || 1, "element with selector '" + selector + "' not found"); | ||
assert.equal(element.attr("type"), type); | ||
return element; | ||
@@ -12,3 +13,3 @@ }; | ||
var element = find(selector); | ||
equal(element.hasClass("hidden"), false); | ||
assert.equal(element.hasClass("hidden"), false); | ||
}; | ||
@@ -18,3 +19,3 @@ | ||
var element = find(selector); | ||
equal(element.hasClass("hidden"), true); | ||
assert.equal(element.hasClass("hidden"), true); | ||
}; | ||
@@ -44,3 +45,3 @@ | ||
var element = assertElement("input[name=%@]".fmt(name), "hidden"); | ||
equal(element.val(), value, "value of '" + value + "' is not equal to the element's value of '" + element.val() + "'"); | ||
assert.equal(element.val(), value, "value of '" + value + "' is not equal to the element's value of '" + element.val() + "'"); | ||
}; | ||
@@ -59,3 +60,3 @@ | ||
var element = assertElement(selector, _type); | ||
equal(element.text(), text); | ||
assert.equal(element.text(), text); | ||
}; | ||
@@ -68,8 +69,8 @@ | ||
equal(control.length, 1, "Unable to find radio button for selector " + selector); | ||
equal(control.attr("type"), "radio", "Element for selector " + selector + " is not a radio button; type is " + control.attr("type")); | ||
ok(control.attr("id"), "Radio button for selector " + selector + " has no id attribute, so it cannot be referred to by a label 'for' attribute"); | ||
assert.equal(control.length, 1, "Unable to find radio button for selector " + selector); | ||
assert.equal(control.attr("type"), "radio", "Element for selector " + selector + " is not a radio button; type is " + control.attr("type")); | ||
assert.ok(control.attr("id"), "Radio button for selector " + selector + " has no id attribute, so it cannot be referred to by a label 'for' attribute"); | ||
equal(label.length, 1, "Unable to find label with 'for' attribute of the selector given for the radio button, " + controlId); | ||
equal(label.text(), text); | ||
assert.equal(label.length, 1, "Unable to find label with 'for' attribute of the selector given for the radio button, " + controlId); | ||
assert.equal(label.text(), text); | ||
}; | ||
@@ -83,7 +84,7 @@ | ||
var element = find(selector); | ||
equal(element.length, 1); | ||
equal(element.text(), text); | ||
assert.equal(element.length, 1); | ||
assert.equal(element.text(), text); | ||
if (href) { | ||
equal(element.attr("href"), href); | ||
assert.equal(element.attr("href"), href); | ||
} | ||
@@ -106,3 +107,3 @@ }; | ||
if (focused.is(expected)) { | ||
ok(true); | ||
assert.ok(true); | ||
} else { | ||
@@ -116,3 +117,3 @@ var tagName = focused.prop("tagName").toLowerCase(); | ||
equal(focused.filter(selector).length, 1, "Expected " + selector + " to have focus, but " + tagName + " has focus"); | ||
assert.equal(focused.filter(selector).length, 1, "Expected " + selector + " to have focus, but " + tagName + " has focus"); | ||
} | ||
@@ -119,0 +120,0 @@ } |
@@ -39,24 +39,14 @@ import Ember from "ember"; | ||
this._createMessage(request, "FIRED"); | ||
ok(false, "Overmocked requests for %@.".fmt(this.get("name"))); | ||
Ember.assert(false, "Overmocked requests for %@.".fmt(this.get("name"))); | ||
}, | ||
_logUnhandledRequests: function(request) { | ||
this._createMessage(request, "MOCKED"); | ||
ok(false, "Unmocked requests for %@.".fmt(this.get("name"))); | ||
Ember.assert(false, "Unmocked requests for %@.".fmt(this.get("name"))); | ||
}, | ||
_logIncorrectRequests: function(request) { | ||
this._incorrectMessage(request.unfired, request.unhandled); | ||
ok(false, "Incorrectly mocked requests for %@.".fmt(this.get("name"))); | ||
Ember.assert(false, "Incorrectly mocked requests for %@.".fmt(this.get("name"))); | ||
}, | ||
_incorrectMessage: function(unfired, unhandled) { | ||
var message = [ | ||
"Request:", | ||
unfired.type, | ||
"to", | ||
unfired.url, | ||
"INCORRECT for", | ||
"'%@'".fmt(this.get("name")), | ||
"in", | ||
"'%@'".fmt(this.get("module")) | ||
]; | ||
console.warn(message.join(" ")); | ||
this._createMessage(unfired, "CORRECT"); | ||
if(unfired.data && !unhandled.data || _.some(_.compact([unfired.data, unhandled.data])) && !_.isEqual(unhandled.data, unfired.data)) { | ||
@@ -90,2 +80,8 @@ this._logObjectData("Mocked data:", unfired.data); | ||
_createMessage: function(request, verb) { | ||
var testNameMessage = [ | ||
this.get("name"), | ||
"in", | ||
this.get("module") | ||
]; | ||
console.warn(testNameMessage.join(" ")); | ||
var message = [ | ||
@@ -96,6 +92,3 @@ "Request:", | ||
request.url, | ||
"not %@ for".fmt(verb), | ||
"'%@'".fmt(this.get("name")), | ||
"in", | ||
"'%@'".fmt(this.get("module")) | ||
"not %@".fmt(verb) | ||
]; | ||
@@ -102,0 +95,0 @@ console.warn(message.join(" ")); |
{ | ||
"name": "ember-cli-test-helpers", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"description": "A collection of test helpers for ember web applications", | ||
@@ -25,17 +25,17 @@ "scripts": { | ||
"devDependencies": { | ||
"bower": "^1.3.12", | ||
"broccoli-asset-rev": "^2.0.0", | ||
"broccoli-ember-hbs-template-compiler": "^1.6.1", | ||
"ember-cli": "0.1.12", | ||
"ember-cli": "0.1.15", | ||
"ember-cli-6to5": "^3.0.0", | ||
"ember-cli-app-version": "0.3.1", | ||
"ember-cli-content-security-policy": "0.3.0", | ||
"ember-cli-dependency-checker": "0.0.7", | ||
"ember-cli-esnext": "0.1.1", | ||
"ember-cli-inject-live-reload": "^1.3.0", | ||
"ember-cli-qunit": "0.3.1", | ||
"ember-cli-app-version": "0.3.1", | ||
"ember-cli-qunit": "0.3.7", | ||
"ember-cli-uglify": "1.0.1", | ||
"ember-export-application-global": "^1.0.0", | ||
"ember-export-application-global": "^1.0.2", | ||
"express": "^4.8.5", | ||
"glob": "^4.0.5" | ||
"glob": "^4.0.5", | ||
"phantomjs": "~1.9.13", | ||
"bower": "^1.3.12" | ||
}, | ||
@@ -42,0 +42,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12810
11
248