Skip to content

Commit

Permalink
test env preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
Alino committed Jul 30, 2018
1 parent 7115d85 commit 95264a1
Show file tree
Hide file tree
Showing 5 changed files with 449 additions and 37 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"scripts": {
"debug": "node debug app.js",
"start": "ts-node app.js",
"test": "ts-node ./node_modules/mocha/bin/mocha --compilers ts:ts-node/register tests/bootstrap.test.js tests/integration/**/*.test.js",
"generateSwagger": "node generateSwaggerFile.js"
},
"main": "app.js",
Expand All @@ -30,6 +31,10 @@
"author": "alino",
"license": "",
"devDependencies": {
"expect": "^23.4.0",
"mocha": "^5.2.0",
"sails-memory": "^0.10.7",
"supertest": "^3.1.0",
"swagger-ui": "^2.2.10"
}
}
29 changes: 29 additions & 0 deletions tests/bootstrap.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var sails = require('sails');

before(function(done) {

// Increase the Mocha timeout so that Sails has enough time to lift.
this.timeout(5000);

sails.lift({
port: 1339,
environment: 'test',
connections: {
testDB: {
adapter: 'sails-memory'
}
},
models: {
connection: 'testDB'
},
}, function(err) {
if (err) return done(err);
// here you can load fixtures, etc.
done(err, sails);
});
});

after(function(done) {
// here you can clear fixtures, etc.
sails.lower(done);
});
21 changes: 21 additions & 0 deletions tests/integration/controllers/JobController.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var request = require('supertest');
var expect = require('expect');

describe('JobController', function() {

describe('GET /job', function() {
it('should return all Jobs', function (done) {
request(sails.hooks.http.app)
.get('/job')
.expect(200)
.then((response) => {
expect(response.body).toEqual([]);
done();
}).catch(err => {
expect(err).not.toBeDefined()
done()
})
});
});

});
14 changes: 14 additions & 0 deletions tests/integration/models/Job.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe('JobModel', function () {

describe('#find()', function () {
it('should check find function', function (done) {
Job.find()
.then(function (results) {
// some tests
done();
})
.catch(done);
});
});

});
Loading

0 comments on commit 95264a1

Please sign in to comment.