fix tests

This commit is contained in:
Philipp Kunz 2016-09-12 23:50:25 +02:00
parent 78bdb6760e
commit 37f388e998
11 changed files with 57 additions and 51 deletions

2
dist/index.d.ts vendored
View File

@ -1,2 +1,2 @@
export * from './smartdata.classes.dbcollection'; export * from './smartdata.classes.dbcollection';
export * from './smartdata.classes.dbconnection'; export * from './smartdata.classes.db';

4
dist/index.js vendored
View File

@ -3,5 +3,5 @@ function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
} }
__export(require('./smartdata.classes.dbcollection')); __export(require('./smartdata.classes.dbcollection'));
__export(require('./smartdata.classes.dbconnection')); __export(require('./smartdata.classes.db'));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWMsa0NBQ2QsQ0FBQyxFQUQrQztBQUNoRCxpQkFBYyxrQ0FDZCxDQUFDLEVBRCtDIn0= //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWMsa0NBQ2QsQ0FBQyxFQUQrQztBQUNoRCxpQkFBYyx3QkFDZCxDQUFDLEVBRHFDIn0=

View File

@ -1,10 +1,10 @@
/// <reference types="q" /> /// <reference types="q" />
import * as plugins from './smartdata.plugins'; import * as plugins from './smartdata.plugins';
export declare type TDbConnectionStatus = 'disconnected' | 'connected' | 'failed'; export declare type TConnectionStatus = 'disconnected' | 'connected' | 'failed';
export declare class DbConnection { export declare class Db {
dbUrl: string; dbUrl: string;
db: plugins.mongodb.Db; db: plugins.mongodb.Db;
status: TDbConnectionStatus; status: TConnectionStatus;
constructor(dbUrl: string); constructor(dbUrl: string);
connect(): plugins.q.Promise<any>; connect(): plugins.q.Promise<any>;
close(): plugins.q.Promise<any>; close(): plugins.q.Promise<any>;

29
dist/smartdata.classes.db.js vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
const plugins = require('./smartdata.plugins');
class Db {
constructor(dbUrl) {
this.dbUrl = dbUrl;
}
connect() {
let done = plugins.q.defer();
plugins.mongodb.MongoClient.connect(this.dbUrl, (err, db) => {
if (err) {
console.log(err);
}
plugins.assert.equal(null, err);
this.db = db;
plugins.beautylog.success(`connected to database at ${this.dbUrl}`);
done.resolve(this.db);
});
return done.promise;
}
close() {
let done = plugins.q.defer();
this.db.close();
plugins.beautylog.ok(`disconnected to database at ${this.dbUrl}`);
done.resolve();
return done.promise;
}
}
exports.Db = Db;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkYXRhLmNsYXNzZXMuZGIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGRhdGEuY2xhc3Nlcy5kYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0scUJBRXpCLENBQUMsQ0FGNkM7QUFJOUM7SUFLSSxZQUFZLEtBQWE7UUFDckIsSUFBSSxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUE7SUFDdEIsQ0FBQztJQUVELE9BQU87UUFDSCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQzVCLE9BQU8sQ0FBQyxPQUFPLENBQUMsV0FBVyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLENBQUMsR0FBRyxFQUFFLEVBQUU7WUFDcEQsRUFBRSxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQztnQkFBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFBO1lBQUMsQ0FBQztZQUM3QixPQUFPLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxJQUFJLEVBQUUsR0FBRyxDQUFDLENBQUE7WUFDL0IsSUFBSSxDQUFDLEVBQUUsR0FBRyxFQUFFLENBQUE7WUFDWixPQUFPLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyw0QkFBNEIsSUFBSSxDQUFDLEtBQUssRUFBRSxDQUFDLENBQUE7WUFDbkUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUE7UUFDekIsQ0FBQyxDQUFDLENBQUE7UUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUN2QixDQUFDO0lBRUQsS0FBSztRQUNELElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDNUIsSUFBSSxDQUFDLEVBQUUsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNmLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLCtCQUErQixJQUFJLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQTtRQUNqRSxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUN2QixDQUFDO0FBQ0wsQ0FBQztBQTVCWSxVQUFFLEtBNEJkLENBQUEifQ==

View File

@ -1,9 +1,9 @@
/// <reference types="q" /> /// <reference types="q" />
import * as plugins from './smartdata.plugins'; import * as plugins from './smartdata.plugins';
import { DbConnection } from './smartdata.classes.dbconnection'; import { Db } from './smartdata.classes.db';
export declare class DbCollection<T> { export declare class DbCollection<T> {
collection: plugins.mongodb.Collection; collection: plugins.mongodb.Collection;
constructor(nameArg: string, dbConnectionArg: DbConnection); constructor(nameArg: string, dbArg: Db);
/** /**
* adds a validation function that all newly inserted and updated objects have to pass * adds a validation function that all newly inserted and updated objects have to pass
*/ */

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
const plugins = require('./smartdata.plugins'); const plugins = require('./smartdata.plugins');
class DbCollection { class DbCollection {
constructor(nameArg, dbConnectionArg) { constructor(nameArg, dbArg) {
this.collection = dbConnectionArg.db.collection(nameArg); this.collection = dbArg.db.collection(nameArg);
} }
/** /**
* adds a validation function that all newly inserted and updated objects have to pass * adds a validation function that all newly inserted and updated objects have to pass
@ -54,4 +54,4 @@ class DbCollection {
} }
} }
exports.DbCollection = DbCollection; exports.DbCollection = DbCollection;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkYXRhLmNsYXNzZXMuZGJjb2xsZWN0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRkYXRhLmNsYXNzZXMuZGJjb2xsZWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFDekIsQ0FBQyxDQUQ2QztBQUc5QztJQUVJLFlBQVksT0FBZSxFQUFFLGVBQTZCO1FBQ3RELElBQUksQ0FBQyxVQUFVLEdBQUcsZUFBZSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDNUQsQ0FBQztJQUVEOztPQUVHO0lBQ0gsbUJBQW1CLENBQUMsT0FBTyxJQUFJLENBQUM7SUFFaEM7O09BRUc7SUFDSCxJQUFJLENBQUMsV0FBb0I7UUFDckIsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQU8sQ0FBQTtRQUNqQyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQyxPQUFPLENBQUMsQ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0FBQTtRQUN4RCxHQUFHLENBQUMsQ0FBQyxJQUFJLE1BQU0sSUFBSSxXQUFXLENBQUMsQ0FBQSxDQUFDO1lBQzVCLG9CQUFvQixDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUE7UUFDcEQsQ0FBQztRQUNELE9BQU8sQ0FBQyxDQUFDLENBQUMsR0FBRyxDQUFDLG9CQUFvQixDQUFDLENBQUMsSUFBSSxDQUFDO1lBQ3JDLElBQUksQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQztpQkFDbEMsSUFBSSxDQUFDLFFBQVEsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFBLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDdkMsQ0FBQyxDQUFDLENBQUE7UUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUN2QixDQUFDO0lBRU8sUUFBUSxDQUFDLEdBQU07UUFDbkIsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQVEsQ0FBQTtRQUNsQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUN2QixDQUFDO0FBQ0wsQ0FBQztBQXhEWSxvQkFBWSxlQXdEeEIsQ0FBQSJ9

View File

@ -1,29 +0,0 @@
"use strict";
const plugins = require('./smartdata.plugins');
class DbConnection {
constructor(dbUrl) {
this.dbUrl = dbUrl;
}
connect() {
let done = plugins.q.defer();
plugins.mongodb.MongoClient.connect(this.dbUrl, (err, db) => {
if (err) {
console.log(err);
}
plugins.assert.equal(null, err);
this.db = db;
plugins.beautylog.success(`connected to database at ${this.dbUrl}`);
done.resolve(this.db);
});
return done.promise;
}
close() {
let done = plugins.q.defer();
this.db.close();
plugins.beautylog.ok(`disconnected to database at ${this.dbUrl}`);
done.resolve();
return done.promise;
}
}
exports.DbConnection = DbConnection;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkYXRhLmNsYXNzZXMuZGJjb25uZWN0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRkYXRhLmNsYXNzZXMuZGJjb25uZWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFFekIsQ0FBQyxDQUY2QztBQUk5QztJQUtJLFlBQVksS0FBYTtRQUNyQixJQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQTtJQUN0QixDQUFDO0lBRUQsT0FBTztRQUNILElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDNUIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQyxHQUFHLEVBQUUsRUFBRTtZQUNwRCxFQUFFLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO2dCQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7WUFBQyxDQUFDO1lBQzdCLE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksRUFBRSxHQUFHLENBQUMsQ0FBQTtZQUMvQixJQUFJLENBQUMsRUFBRSxHQUFHLEVBQUUsQ0FBQTtZQUNaLE9BQU8sQ0FBQyxTQUFTLENBQUMsT0FBTyxDQUFDLDRCQUE0QixJQUFJLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQTtZQUNuRSxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQTtRQUN6QixDQUFDLENBQUMsQ0FBQTtRQUNGLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7SUFFRCxLQUFLO1FBQ0QsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUM1QixJQUFJLENBQUMsRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ2YsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsK0JBQStCLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQyxDQUFBO1FBQ2pFLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNkLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7QUFDTCxDQUFDO0FBNUJZLG9CQUFZLGVBNEJ4QixDQUFBIn0=

0
dist/smartdata.classes.dbdoc.d.ts vendored Normal file
View File

1
dist/smartdata.classes.dbdoc.js vendored Normal file
View File

@ -0,0 +1 @@
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkYXRhLmNsYXNzZXMuZGJkb2MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGRhdGEuY2xhc3Nlcy5kYmRvYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=

View File

@ -6,8 +6,13 @@ const smartstring = require('smartstring');
// the tested module // the tested module
const smartdata = require('../dist/index'); const smartdata = require('../dist/index');
let mongoChildProcess; let mongoChildProcess;
let testDbConnection; let testDb;
let testDbCollection; let testDbCollection;
class testCar {
constructor(colorArg) {
this.color = colorArg;
}
}
describe('mongodb', function () { describe('mongodb', function () {
it('should start mongodb', function (done) { it('should start mongodb', function (done) {
this.timeout(30000); this.timeout(30000);
@ -26,11 +31,11 @@ describe('mongodb', function () {
}); });
describe('smartdata', function () { describe('smartdata', function () {
it('should establish a connection to mongodb', function (done) { it('should establish a connection to mongodb', function (done) {
testDbConnection = new smartdata.DbConnection('mongodb://localhost:27017/smartdata'); testDb = new smartdata.Db('mongodb://localhost:27017/smartdata');
testDbConnection.connect().then(() => { done(); }); testDb.connect().then(() => { done(); });
}); });
it('should create a collection', function () { it('should create a collection', function () {
testDbCollection = new smartdata.DbCollection('something', testDbConnection); testDbCollection = new smartdata.DbCollection('something', testDb);
}); });
it('should insert a doc into the collection', function (done) { it('should insert a doc into the collection', function (done) {
testDbCollection.insertOne({ value1: 'test' }).then(() => { done(); }); testDbCollection.insertOne({ value1: 'test' }).then(() => { done(); });
@ -56,7 +61,7 @@ describe('smartdata', function () {
}).catch(console.log); }).catch(console.log);
}); });
it('should close the db Connection', function () { it('should close the db Connection', function () {
testDbConnection.close(); testDb.close();
}); });
}); });
describe('mongodb', function () { describe('mongodb', function () {
@ -71,4 +76,4 @@ describe('mongodb', function () {
mongoChildProcess.kill('SIGTERM'); mongoChildProcess.kill('SIGTERM');
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FFUCxDQUFDLENBRm9CO0FBRXJCLE1BQVksT0FBTyxXQUFNLFNBQ3pCLENBQUMsQ0FEaUM7QUFDbEMsTUFBWSxNQUFNLFdBQU0sUUFDeEIsQ0FBQyxDQUQrQjtBQUNoQyxNQUFZLFdBQVcsV0FBTSxhQUc3QixDQUFDLENBSHlDO0FBRTFDLG9CQUFvQjtBQUNwQixNQUFZLFNBQVMsV0FBTSxlQUUzQixDQUFDLENBRnlDO0FBRTFDLElBQUksaUJBQWlCLENBQUE7QUFDckIsSUFBSSxnQkFBd0MsQ0FBQTtBQVE1QyxJQUFJLGdCQUFzRCxDQUFBO0FBSTFELFFBQVEsQ0FBQyxTQUFTLEVBQUU7SUFDaEIsR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CQUFpQixDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNyQyxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFBIn0=

View File

@ -8,7 +8,7 @@ import * as smartstring from 'smartstring'
import * as smartdata from '../dist/index' import * as smartdata from '../dist/index'
let mongoChildProcess let mongoChildProcess
let testDbConnection: smartdata.DbConnection let testDb: smartdata.Db
interface ITestObject1 { interface ITestObject1 {
value1: string value1: string
@ -45,11 +45,11 @@ describe('mongodb', function () {
describe('smartdata', function () { describe('smartdata', function () {
it('should establish a connection to mongodb', function (done) { it('should establish a connection to mongodb', function (done) {
testDbConnection = new smartdata.DbConnection('mongodb://localhost:27017/smartdata') testDb = new smartdata.Db('mongodb://localhost:27017/smartdata')
testDbConnection.connect().then(() => { done() }) testDb.connect().then(() => { done() })
}) })
it('should create a collection', function () { it('should create a collection', function () {
testDbCollection = new smartdata.DbCollection<ITestObject1>('something', testDbConnection) testDbCollection = new smartdata.DbCollection<ITestObject1>('something', testDb)
}) })
it('should insert a doc into the collection', function (done) { it('should insert a doc into the collection', function (done) {
testDbCollection.insertOne({ value1: 'test' }).then(() => { done() }) testDbCollection.insertOne({ value1: 'test' }).then(() => { done() })
@ -75,7 +75,7 @@ describe('smartdata', function () {
}).catch(console.log) }).catch(console.log)
}) })
it('should close the db Connection', function () { it('should close the db Connection', function () {
testDbConnection.close() testDb.close()
}) })
}) })