-
Notifications
You must be signed in to change notification settings - Fork 33
/
test.js
40 lines (39 loc) · 963 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var db = require('./index.js').db,
expect = require('chai').expect;
describe('Postgres Database', function () {
this.timeout(3000);
beforeEach(function (done) {
setTimeout(function () {
done();
}, 1000);
});
it('should create a table', function (done) {
db.schema.hasTable('things').then(function (exists) {
if (!exists) {
db.schema.createTable('things', function (table) {
table.string('name');
}).then(function () {
done();
});
} else {
done();
}
});
});
it('should save a new name', function (done) {
db('things')
.insert({ name: 'Johnson' })
.exec(function (err) {
expect(err).to.equal(null);
done();
});
});
it('should retrieve that name', function (done) {
db('things')
.select()
.then(function (docs) {
expect(docs[0].name).to.equal('Johnson');
done();
});
});
});