mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-01 00:08:27 +01:00
Cleaning up tests: e2e vs unit #102
This commit is contained in:
parent
5de3e659d3
commit
de6ea81af8
@ -35,12 +35,12 @@
|
||||
"start:dev:pg": "pg_virtualenv npm run start:dev:pg-chain",
|
||||
"start:dev:pg-chain": "export DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@localhost:$PGPORT/postgres ; db-migrate up && npm run start:dev",
|
||||
"db-migrate": "db-migrate up",
|
||||
"test": "export PORT=4243 ; mocha test test/*.js && npm run test:coverage",
|
||||
"test": "export PORT=4243 ; mocha test/**/*.js && npm run test:coverage",
|
||||
"test:ci": "npm run db-migrate && npm run test",
|
||||
"test:watch": "mocha --watch test test/*",
|
||||
"test:pg-virtualenv": "pg_virtualenv npm run test:pg-virtualenv-chai",
|
||||
"test:pg-virtualenv-chain": "export TEST_DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@localhost:$PGPORT/postgres ; npm run db-migrate-testdb && npm test",
|
||||
"test:coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec",
|
||||
"test:coverage": "istanbul cover ./node_modules/mocha/bin/_mocha test/**/*.js --report lcovonly -- -R spec",
|
||||
"test:coverage-report": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -64,6 +64,7 @@
|
||||
"istanbul": "^0.4.3",
|
||||
"mocha": "^2.4.5",
|
||||
"mocha-lcov-reporter": "1.2.0",
|
||||
"sinon": "^1.17.5",
|
||||
"supertest": "^1.2.0",
|
||||
"supervisor": "^0.10.0",
|
||||
"unleash-frontend": "1.0.0-alpha.2"
|
||||
|
@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
const logger = require('../lib/logger');
|
||||
const logger = require('../../lib/logger');
|
||||
const assert = require('assert');
|
||||
const specHelper = require('./specHelper');
|
||||
const request = specHelper.request;
|
@ -4,14 +4,14 @@ process.env.NODE_ENV = 'test';
|
||||
const BPromise = require('bluebird');
|
||||
let request = require('supertest');
|
||||
const databaseUri = require('./databaseConfig').getDatabaseUri();
|
||||
const knex = require('../lib/db/dbPool')(databaseUri);
|
||||
const eventDb = require('../lib/db/event')(knex);
|
||||
const EventStore = require('../lib/eventStore');
|
||||
const knex = require('../../lib/db/dbPool')(databaseUri);
|
||||
const eventDb = require('../../lib/db/event')(knex);
|
||||
const EventStore = require('../../lib/eventStore');
|
||||
const eventStore = new EventStore(eventDb);
|
||||
const featureDb = require('../lib/db/feature')(knex, eventStore);
|
||||
const strategyDb = require('../lib/db/strategy')(knex, eventStore);
|
||||
const featureDb = require('../../lib/db/feature')(knex, eventStore);
|
||||
const strategyDb = require('../../lib/db/strategy')(knex, eventStore);
|
||||
|
||||
const app = require('../app')({
|
||||
const app = require('../../app')({
|
||||
baseUriPath: '',
|
||||
db: knex,
|
||||
eventDb,
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
const eventDiffer = require('../lib/eventDiffer');
|
||||
const eventType = require('../lib/eventType');
|
||||
const eventDiffer = require('../../lib/eventDiffer');
|
||||
const eventType = require('../../lib/eventType');
|
||||
const assert = require('assert');
|
||||
|
||||
describe('eventDiffer', () => {
|
60
packages/unleash-api/test/unit/routes/feature.test.js
Normal file
60
packages/unleash-api/test/unit/routes/feature.test.js
Normal file
@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
let supertest = require('supertest');
|
||||
const BPromise = require('bluebird');
|
||||
BPromise.promisifyAll(supertest);
|
||||
const assert = require('assert');
|
||||
const sinon = require('sinon');
|
||||
|
||||
let request;
|
||||
let featureDb;
|
||||
|
||||
describe('Unit: The features api', () => {
|
||||
beforeEach(done => {
|
||||
featureDb = createFeatureDb();
|
||||
|
||||
const app = require('../../../app')({
|
||||
baseUriPath: '',
|
||||
db: sinon.stub(),
|
||||
eventDb: sinon.stub(),
|
||||
eventStore: sinon.stub(),
|
||||
featureDb: featureDb,
|
||||
strategyDb: sinon.stub(),
|
||||
});
|
||||
|
||||
request = supertest(app);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should get empty getFeatures', (done) => {
|
||||
request
|
||||
.get('/features')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end((err, res) => {
|
||||
assert(res.body.features.length === 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get one getFeature', (done) => {
|
||||
featureDb.addFeature( { name: 'test', strategies: [{ name: 'default' }] } );
|
||||
|
||||
request
|
||||
.get('/features')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end((err, res) => {
|
||||
assert(res.body.features.length === 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function createFeatureDb () {
|
||||
let _features = [];
|
||||
return {
|
||||
getFeatures: () => BPromise.resolve(_features),
|
||||
addFeature: (feature) => _features.push(feature),
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user