From fda47177ffb01dd7d848141eef08bbc06aba4e5e Mon Sep 17 00:00:00 2001 From: Hans Kristian Flaatten Date: Sun, 3 Jul 2016 22:02:08 +0200 Subject: [PATCH] feat(data): add `api.users` test data --- README.md | 8 +++++++ data/api.users.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++ index.js | 7 ++++++ package.json | 53 ++++++++++++++++++++++++++++++++++++++++ test.js | 23 ++++++++++++++++++ 5 files changed, 152 insertions(+) create mode 100644 data/api.users.js create mode 100644 index.js create mode 100644 package.json create mode 100644 test.js diff --git a/README.md b/README.md index 0f90037..6fb0923 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,14 @@ Run in this directory: $ docker-compose up ``` +## Usage + +### api.users + +```js +const users = require('@turbasen/test-data').api.users; +``` + Docker is now watching for changes and will run the test suite automatically. ## [MIT lisenced](https://github.com/Turbasen/test-data/blob/master/LICENSE) diff --git a/data/api.users.js b/data/api.users.js new file mode 100644 index 0000000..4c3539c --- /dev/null +++ b/data/api.users.js @@ -0,0 +1,61 @@ +'use strict'; + +const ObjectID = require('mongodb').ObjectID; + +module.exports = [ + { + _id: new ObjectID('100000000000000000000000'), + provider: 'FOO', + apps: [ + { + _id: new ObjectID('100000000000000000000001'), + name: 'foo_app1', + limit: { + test: 499, + dev: 500, + prod: 5000, + }, + key: { + test: 'foo_app1_test', + dev: 'foo_app1_dev', + prod: 'foo_app1_prod', + }, + active: true, + }, + ], + }, { + _id: new ObjectID('200000000000000000000000'), + provider: 'FOO', + apps: [ + { + _id: new ObjectID('200000000000000000000001'), + name: 'bar_app1', + limit: { + test: 499, + dev: 500, + prod: 5000, + }, + key: { + test: 'bar_app1_test', + dev: 'bar_app1_dev', + prod: 'bar_app1_prod', + }, + active: true, + }, { + _id: new ObjectID('200000000000000000000002'), + name: 'bar_app2', + limit: { + test: 499, + dev: 500, + prod: 5000, + }, + key: { + test: 'bar_app2_test', + dev: 'bar_app2_dev', + prod: 'bar_app2_prod', + }, + active: true, + }, + ], + }, +]; diff --git a/index.js b/index.js new file mode 100644 index 0000000..946d4f1 --- /dev/null +++ b/index.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = { + api: { + users: require('./data/api.users'), + }, +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..14f5ae9 --- /dev/null +++ b/package.json @@ -0,0 +1,53 @@ +{ + "name": "@turbasen/test-data", + "version": null, + "description": "Test data for internal Nasjonal Turbase API development", + "main": "index.js", + "files": [ + "index.js" + ], + "scripts": { + "codacy-coverage": "codacy-coverage", + "cover": "istanbul cover --report lcovonly ./node_modules/.bin/_mocha -- -R spec test.js", + "grunt:watch": "grunt watch", + "lint": "eslint index.js test.js", + "nsp": "nsp check", + "semantic-release": "semantic-release", + "test": "mocha -R tap -b --check-leaks test.js", + "test:watch": "mocha -R progress -b --check-leaks -w test.js", + "greenkeeper-postpublish": "greenkeeper-postpublish" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Turbasen/test-data.git" + }, + "keywords": [ + "nasjonal turbase", + "turbasen", + "test", + "data" + ], + "author": "Hans Kristian Flaatten ", + "license": "MIT", + "bugs": { + "url": "https://github.com/Turbasen/test-data/issues" + }, + "homepage": "https://github.com/Turbasen/test-data#readme", + "dependencies": { + "mongodb": "^2.1.18" + }, + "devDependencies": { + "codacy-coverage": "^1.1.3", + "eslint": "^2.13.1", + "eslint-config-airbnb-base": "^3.0.1", + "eslint-plugin-import": "^1.10.0", + "greenkeeper-postpublish": "^1.0.0", + "istanbul": "^0.4.4", + "mocha": "^2.5.3", + "nsp": "^2.5.0", + "semantic-release": "^4.3.5" + }, + "engines": { + "node": ">=4.0.0" + } +} diff --git a/test.js b/test.js new file mode 100644 index 0000000..22ee36f --- /dev/null +++ b/test.js @@ -0,0 +1,23 @@ +'use strict'; + +const data = require('.'); +const assert = require('assert'); +const ObjectID = require('mongodb').ObjectID; + +describe('data', () => { + it('exports test data', () => { + assert.deepEqual(Object.keys(data), ['api']); + assert.deepEqual(Object.keys(data.api), ['users']); + }); +}); + +describe('api.users', () => { + it('exports api users', () => { + assert(data.api.users instanceof Array); + assert.equal(data.api.users.length, 2); + + data.api.users.forEach(user => { + assert(user._id instanceof ObjectID); + }); + }); +});