Skip to content

Commit fda4717

Browse files
author
Hans Kristian Flaatten
committed
feat(data): add api.users test data
1 parent 3275a92 commit fda4717

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ Run in this directory:
2020
$ docker-compose up
2121
```
2222

23+
## Usage
24+
25+
### api.users
26+
27+
```js
28+
const users = require('@turbasen/test-data').api.users;
29+
```
30+
2331
Docker is now watching for changes and will run the test suite automatically.
2432

2533
## [MIT lisenced](https://github.com/Turbasen/test-data/blob/master/LICENSE)

data/api.users.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
'use strict';
2+
3+
const ObjectID = require('mongodb').ObjectID;
4+
5+
module.exports = [
6+
{
7+
_id: new ObjectID('100000000000000000000000'),
8+
provider: 'FOO',
9+
apps: [
10+
{
11+
_id: new ObjectID('100000000000000000000001'),
12+
name: 'foo_app1',
13+
limit: {
14+
test: 499,
15+
dev: 500,
16+
prod: 5000,
17+
},
18+
key: {
19+
test: 'foo_app1_test',
20+
dev: 'foo_app1_dev',
21+
prod: 'foo_app1_prod',
22+
},
23+
active: true,
24+
},
25+
],
26+
}, {
27+
_id: new ObjectID('200000000000000000000000'),
28+
provider: 'FOO',
29+
apps: [
30+
{
31+
_id: new ObjectID('200000000000000000000001'),
32+
name: 'bar_app1',
33+
limit: {
34+
test: 499,
35+
dev: 500,
36+
prod: 5000,
37+
},
38+
key: {
39+
test: 'bar_app1_test',
40+
dev: 'bar_app1_dev',
41+
prod: 'bar_app1_prod',
42+
},
43+
active: true,
44+
}, {
45+
_id: new ObjectID('200000000000000000000002'),
46+
name: 'bar_app2',
47+
limit: {
48+
test: 499,
49+
dev: 500,
50+
prod: 5000,
51+
},
52+
key: {
53+
test: 'bar_app2_test',
54+
dev: 'bar_app2_dev',
55+
prod: 'bar_app2_prod',
56+
},
57+
active: true,
58+
},
59+
],
60+
},
61+
];

index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
module.exports = {
4+
api: {
5+
users: require('./data/api.users'),
6+
},
7+
};

package.json

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "@turbasen/test-data",
3+
"version": null,
4+
"description": "Test data for internal Nasjonal Turbase API development",
5+
"main": "index.js",
6+
"files": [
7+
"index.js"
8+
],
9+
"scripts": {
10+
"codacy-coverage": "codacy-coverage",
11+
"cover": "istanbul cover --report lcovonly ./node_modules/.bin/_mocha -- -R spec test.js",
12+
"grunt:watch": "grunt watch",
13+
"lint": "eslint index.js test.js",
14+
"nsp": "nsp check",
15+
"semantic-release": "semantic-release",
16+
"test": "mocha -R tap -b --check-leaks test.js",
17+
"test:watch": "mocha -R progress -b --check-leaks -w test.js",
18+
"greenkeeper-postpublish": "greenkeeper-postpublish"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/Turbasen/test-data.git"
23+
},
24+
"keywords": [
25+
"nasjonal turbase",
26+
"turbasen",
27+
"test",
28+
"data"
29+
],
30+
"author": "Hans Kristian Flaatten <[email protected]>",
31+
"license": "MIT",
32+
"bugs": {
33+
"url": "https://github.com/Turbasen/test-data/issues"
34+
},
35+
"homepage": "https://github.com/Turbasen/test-data#readme",
36+
"dependencies": {
37+
"mongodb": "^2.1.18"
38+
},
39+
"devDependencies": {
40+
"codacy-coverage": "^1.1.3",
41+
"eslint": "^2.13.1",
42+
"eslint-config-airbnb-base": "^3.0.1",
43+
"eslint-plugin-import": "^1.10.0",
44+
"greenkeeper-postpublish": "^1.0.0",
45+
"istanbul": "^0.4.4",
46+
"mocha": "^2.5.3",
47+
"nsp": "^2.5.0",
48+
"semantic-release": "^4.3.5"
49+
},
50+
"engines": {
51+
"node": ">=4.0.0"
52+
}
53+
}

test.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const data = require('.');
4+
const assert = require('assert');
5+
const ObjectID = require('mongodb').ObjectID;
6+
7+
describe('data', () => {
8+
it('exports test data', () => {
9+
assert.deepEqual(Object.keys(data), ['api']);
10+
assert.deepEqual(Object.keys(data.api), ['users']);
11+
});
12+
});
13+
14+
describe('api.users', () => {
15+
it('exports api users', () => {
16+
assert(data.api.users instanceof Array);
17+
assert.equal(data.api.users.length, 2);
18+
19+
data.api.users.forEach(user => {
20+
assert(user._id instanceof ObjectID);
21+
});
22+
});
23+
});

0 commit comments

Comments
 (0)