Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
bardjs Change Log
===================
### 0.1.9
- Changed verifyNoOutstandingHttpRequests to wrap its verification in a try/catch so mocha can be informed about the error in a nice way that doesn't halt the test suite
- Changed the mockService function to create a stub instead of a spy when the value of a config obj property is a non-function value. This makes it possible to dynamically configure the stub while testing

### 0.1.8
- no functional changes.
- reversed 0.1.7. Apparently [peerDependecies are a horrible idea](https://github.com/npm/npm/issues/5080) and have been deprecated. It also seems that bardjs is DIRECTLY dependent on sinon so it's back to being a dependency.
Expand Down
18 changes: 12 additions & 6 deletions bard.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,7 @@
if (typeof value === 'function') {
sinon.stub(service, key, value);
} else {
sinon.stub(service, key, function() {
return value;
});
sinon.stub(service, key).returns(value);
}
} else {
service[key] = value;
Expand Down Expand Up @@ -631,9 +629,17 @@
* For use with ngMocks; doesn't work for async server integration tests
*/
function verifyNoOutstandingHttpRequests () {
afterEach(angular.mock.inject(function($httpBackend) {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
afterEach(angular.mock.inject(function ($httpBackend) {
try {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
} catch (e) {
if (e instanceof Error) {
this.test.error(e); //signal error to mocha - see https://github.com/mochajs/mocha/wiki/Conditionally-failing-tests-in-afterEach()-hooks
} else {
throw e; //nothing we can do - this will halt the suite as long as https://github.com/mochajs/mocha/issues/1635 is not fixed
}
}
}));
}

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bardjs",
"version": "0.1.8",
"version": "0.1.9",
"description": "Spec helpers for testing angular v.1.x apps with Mocha, Jasmine or QUnit",
"authors": [
"John Papa",
Expand Down
2 changes: 1 addition & 1 deletion dist/bard-ngRouteTester.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* bardjs - Spec helpers for testing angular v.1.x apps with Mocha, Jasmine or QUnit
* @authors John Papa,Ward Bell
* @version v0.1.8
* @version v0.1.9
* @link https://github.com/wardbell/bardjs
* @license MIT
*/
Expand Down
22 changes: 14 additions & 8 deletions dist/bard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* bardjs - Spec helpers for testing angular v.1.x apps with Mocha, Jasmine or QUnit
* @authors John Papa,Ward Bell
* @version v0.1.8
* @version v0.1.9
* @link https://github.com/wardbell/bardjs
* @license MIT
*/
Expand Down Expand Up @@ -561,11 +561,9 @@

if (typeof service[key] === 'function') {
if (typeof value === 'function') {
service[key] = value;
sinon.stub(service, key, value);
} else {
sinon.stub(service, key, function() {
return value;
});
sinon.stub(service, key).returns(value);
}
} else {
service[key] = value;
Expand Down Expand Up @@ -638,9 +636,17 @@
* For use with ngMocks; doesn't work for async server integration tests
*/
function verifyNoOutstandingHttpRequests () {
afterEach(angular.mock.inject(function($httpBackend) {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
afterEach(angular.mock.inject(function ($httpBackend) {
try {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
} catch (e) {
if (e instanceof Error) {
this.test.error(e); //signal error to mocha - see https://github.com/mochajs/mocha/wiki/Conditionally-failing-tests-in-afterEach()-hooks
} else {
throw e; //nothing we can do - this will halt the suite as long as https://github.com/mochajs/mocha/issues/1635 is not fixed
}
}
}));
}

Expand Down
2 changes: 1 addition & 1 deletion dist/bard.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bardjs",
"version": "0.1.8",
"version": "0.1.9",
"description": "Spec helpers for testing angular v.1.x apps with Mocha, Jasmine or QUnit",
"repository": {
"type": "git",
Expand Down