34 lines
2.9 KiB
JavaScript
34 lines
2.9 KiB
JavaScript
"use strict";
|
|
require('typings-test');
|
|
const shelljs = require('shelljs');
|
|
const smartdata = require('../dist/index');
|
|
let mongoChildProcess;
|
|
let testDbConnection;
|
|
let testDbCollection;
|
|
describe('mongodb', function () {
|
|
it('should start mongodb', function (done) {
|
|
this.timeout(10000);
|
|
mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017', { async: true });
|
|
setTimeout(() => { done(); }, 5000); // give mongodb it some time to complete startup
|
|
});
|
|
});
|
|
describe('smartdata', function () {
|
|
it('should establish a connection to mongodb', function (done) {
|
|
testDbConnection = new smartdata.DbConnection('mongodb://localhost:27017/smartdata');
|
|
testDbConnection.connect().then(() => { done(); });
|
|
});
|
|
it('should create a collection', function () {
|
|
testDbCollection = new smartdata.DbCollection('something', testDbConnection);
|
|
});
|
|
it('should close the db Connection', function () {
|
|
testDbConnection.close();
|
|
});
|
|
});
|
|
describe('mongodb', function () {
|
|
it('should kill mongodb', function () {
|
|
this.timeout(10000);
|
|
shelljs.exec('mongod --dbpath=./test/data --shutdown');
|
|
mongoChildProcess.kill('SIGTERM');
|
|
});
|
|
});
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLE1BQVksT0FBTyxXQUFNLFNBQ3pCLENBQUMsQ0FEaUM7QUFFbEMsTUFBWSxTQUFTLFdBQU0sZUFHM0IsQ0FBQyxDQUh5QztBQUcxQyxJQUFJLGlCQUFpQixDQUFBO0FBQ3JCLElBQUksZ0JBQXdDLENBQUE7QUFDNUMsSUFBSSxnQkFBNkMsQ0FBQTtBQUdqRCxRQUFRLENBQUMsU0FBUyxFQUFDO0lBQ2YsRUFBRSxDQU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