Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 3977b64

Browse files
author
Miroslav Bajtoš
committed
Merge branch 'release/0.2.1' into production
2 parents 5231a8b + af64d8e commit 3977b64

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

lib/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ _describe.whenCalledRemotely = function(verb, url, data, cb) {
156156
describe(verb.toUpperCase() + ' ' + urlStr, function() {
157157
beforeEach(function(cb) {
158158
if(typeof url === 'function') {
159-
url = url.call(this);
159+
this.url = url.call(this);
160160
}
161161
this.remotely = true;
162162
this.verb = verb.toUpperCase();

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "loopback-testing",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Utilities for testing LoopBack applications",
55
"main": "index.js",
66
"scripts": {
@@ -17,6 +17,10 @@
1717
"chai": "~1.9.0",
1818
"loopback": "^1.6.1"
1919
},
20+
"repository": {
21+
"type": "git",
22+
"url": "https://github.com/strongloop/loopback-testing"
23+
},
2024
"license": {
2125
"name": "Dual MIT/StrongLoop",
2226
"url": "https://github.com/strongloop/loopback-testing/blob/master/LICENSE"

test/test.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ describe('helpers', function () {
1212

1313
describe('helpers.it', function() {
1414
['shouldBeAllowed',
15-
'shouldBeDenied']
15+
'shouldBeDenied',
16+
'shouldNotBeFound',
17+
'shouldBeAllowedWhenCalledAnonymously',
18+
'shouldBeDeniedWhenCalledAnonymously',
19+
'shouldBeAllowedWhenCalledUnauthenticated',
20+
'shouldBeDeniedWhenCalledUnauthenticated',
21+
'shouldBeAllowedWhenCalledByUser',
22+
'shouldBeDeniedWhenCalledByUser']
1623
.forEach(function(func) {
1724
it('should have a method named ' + func, function () {
1825
assert.equal(typeof helpers.it[func], 'function');
@@ -22,8 +29,11 @@ describe('helpers', function () {
2229

2330
describe('helpers.describe', function() {
2431
['staticMethod',
32+
'instanceMethod',
2533
'whenLoggedInAsUser',
26-
'whenCalledAnonymously']
34+
'whenCalledByUser',
35+
'whenCalledAnonymously',
36+
'whenCalledUnauthenticated']
2737
.forEach(function(func) {
2838
it('should have a method named ' + func, function () {
2939
assert.equal(typeof helpers.describe[func], 'function');
@@ -34,7 +44,10 @@ describe('helpers', function () {
3444
describe('helpers.beforeEach', function() {
3545
['withArgs',
3646
'givenModel',
37-
'givenUser']
47+
'givenUser',
48+
'givenLoggedInUser',
49+
'givenAnUnauthenticatedToken',
50+
'givenAnAnonymousToken']
3851
.forEach(function(func) {
3952
it('should have a helper method named ' + func, function () {
4053
assert.equal(typeof helpers.beforeEach[func], 'function');
@@ -59,5 +72,18 @@ describe('helpers', function () {
5972
});
6073
});
6174
});
75+
helpers.describe.staticMethod('findById', function() {
76+
helpers.beforeEach.givenModel('xxx-test-model', {foo: 'bar'});
77+
helpers.describe.whenCalledRemotely('GET', function () {
78+
return '/xxx-test-models/' + this['xxx-test-model'].id;
79+
}, function() {
80+
it('should retrieve the expected model in the first test', function () {
81+
assert.equal(this.res.body.id, this['xxx-test-model'].id);
82+
});
83+
it('should retrieve the expected model in subsequent tests', function () {
84+
assert.equal(this.res.body.id, this['xxx-test-model'].id);
85+
});
86+
});
87+
});
6288
});
6389
});

0 commit comments

Comments
 (0)