ember-cli-custom-assertions-collection
Advanced tools
Comparing version 1.0.0-rc.1 to 1.0.0-rc.2
@@ -10,4 +10,17 @@ # Change Log | ||
## [1.0.0] - 2015-10-01 | ||
## [1.0.0-rc.2] - 2015-10-01 | ||
### Added | ||
- Ability to test the testing callback with optional arguments using `argsLength`. | ||
### Fixed | ||
- numbersAlmostEqual failed to work with optional arguments. | ||
### Documentation | ||
- Added DivShot config. | ||
## [1.0.0-rc.1] - 2015-10-01 | ||
Woot! A stable release! | ||
@@ -14,0 +27,0 @@ |
{ | ||
"name": "ember-cli-custom-assertions-collection", | ||
"version": "1.0.0-rc.1", | ||
"version": "1.0.0-rc.2", | ||
"description": "An ever growing library of assertions for QUnit in Ember.", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -383,5 +383,6 @@ [![Travis](https://travis-ci.org/lolmaus/ember-cli-custom-assertions-collection.svg)](https://travis-ci.org/lolmaus/ember-cli-custom-assertions-collection) | ||
{ | ||
args: [ 'foo', 'bar', 'baz' ], // (array) arguments that will be passed into the testing callback | ||
result: true, // (boolean) what result to expect | ||
desc: "testing three strings" // (string, optional) Lets similar-looking test cases appear different in test results | ||
args: [ 'foo', 'bar', 'baz' ], // (array) arguments that will be passed into the testing callback | ||
result: true, // (boolean) what result to expect | ||
desc: "testing three strings", // (string, optional) Lets similar-looking test cases appear different in test results | ||
argsLength: 4 // (int, optional) To test optional arguments | ||
} | ||
@@ -408,2 +409,6 @@ ``` | ||
If your test callback has optional argument(s) and in your test case `args` contains fewer arguments that the callback's footprint, then you have to provide `argsLength` with a total number of arguments. See the | ||
`numbers-almost-equal` [assertion](https://github.com/lolmaus/ember-cli-custom-assertions-collection/blob/generation-2/test-support/assertions/numbers-almost-equal.js#L5-L7) and [test](https://github.com/lolmaus/ember-cli-custom-assertions-collection/blob/generation-2/tests/unit/assertions/numbers-almost-equal-test.js#L22-23) for an example. | ||
#### Testing a trivial assertion that does not have a testing callback exposed | ||
@@ -410,0 +415,0 @@ |
@@ -5,7 +5,2 @@ import _ from 'npm:lodash'; | ||
export function testNumbersAlmostEqual(actual, expected, precision) { | ||
if (_.isString(precision)) { | ||
message = precision; | ||
} | ||
if (!_.isNumber(precision)) { | ||
@@ -12,0 +7,0 @@ precision = 6; |
import { test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
import sinon from 'sinon'; | ||
import _ from 'npm:lodash'; | ||
@@ -23,4 +24,10 @@ export default function testAssertion (testCases, asserter, assertionPusher, message, appContext) { | ||
assertionPusher.call(obj, appContext, ...testCase.args); | ||
// Padding the args array using the testCase.argsLength value | ||
let args = [].concat(testCase.args); | ||
if (testCase.argsLength) { | ||
args = _.merge( Array.apply(null, Array(testCase.argsLength)), args ); | ||
} | ||
assertionPusher.call(obj, appContext, ...args); | ||
sinon.assert.calledOnce(spy); | ||
@@ -40,3 +47,3 @@ sinon.assert.calledWithExactly(spy, testCase.result, firstArg, secondArg, message); | ||
spy = obj.push = sinon.spy(); | ||
assertionPusher.call(obj, appContext, ...testCase.args, 'Foo'); | ||
assertionPusher.call(obj, appContext, ...args, 'Foo'); | ||
@@ -43,0 +50,0 @@ sinon.assert.calledOnce(spy); |
Sorry, the diff of this file is not supported yet
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
116547
57
209
494
0