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

Commit 46b6513

Browse files
committed
Merge branch 'release/0.0.4' into production
2 parents d10a03d + c437b15 commit 46b6513

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,37 @@ describe('/products', function() {
4545
});
4646
});
4747
```
48+
49+
## building test data
50+
51+
Use TestDataBuilder to build many Model instances in one async call. Specify
52+
only properties relevant to your test, the builder will pre-fill remaining
53+
required properties with sensible defaults.
54+
55+
```js
56+
var TestDataBuilder = require('loopback-testing').TestDataBuilder;
57+
var ref = TestDataBuilder.ref;
58+
59+
// The context object to hold the created models.
60+
// You can use `this` in mocha test instead.
61+
var context = {};
62+
63+
var ref = TestDataBuilder.ref;
64+
new TestDataBuilder()
65+
.define('application', Application, {
66+
pushSettings: { stub: { } }
67+
})
68+
.define('device', Device, {
69+
// use the value of application's id
70+
// the value is resolved at build time
71+
appId: ref('application.id'),
72+
deviceType: 'android'
73+
})
74+
.define('notification', Notification)
75+
.buildTo(context, function(err) {
76+
// test models are available as
77+
// context.application
78+
// context.device
79+
// context.notification
80+
});
81+
```

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "loopback-testing",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "Utilities for testing LoopBack applications",
55
"main": "index.js",
66
"scripts": {
@@ -13,10 +13,13 @@
1313
"supertest": "~0.8.2",
1414
"mocha": "~1.15.1",
1515
"loopback-datasource-juggler": "~1.2.7",
16-
"loopback": "~1.3.3",
1716
"async": "~0.2.9"
1817
},
18+
"peerDependencies": {
19+
"loopback": "~1.3.3"
20+
},
1921
"devDependencies": {
20-
"chai": "~1.8.1"
22+
"chai": "~1.8.1",
23+
"loopback": "~1.3.3"
2124
}
2225
}

0 commit comments

Comments
 (0)