Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kimamula committed Oct 27, 2019
1 parent fea7a43 commit 3d3faaa
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions test/promisify_run.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,31 @@ if (typeof util.promisify === 'function') {
promisifyedDbRun = util.promisify(db.run).bind(db);
});

it('should create the table', function(done) {
promisifyedDbRun("CREATE TABLE foo (txt TEXT, num INT)")
it('should create the table', function() {
return promisifyedDbRun("CREATE TABLE foo (txt TEXT, num INT)")
.then(function(result) {
assert.deepEqual(result, {
changes: 0,
lastID: 0,
sql: 'CREATE TABLE foo (txt TEXT, num INT)'
});
done();
})
.catch(done);
assert.equal(result.changes, 0);
assert.equal(result.lastID, 0);
});
});

it('should insert a value without placeholders', function(done) {
promisifyedDbRun("INSERT INTO foo VALUES('Lorem Ipsum', 1)")
it('should insert a value without placeholders', function() {
return promisifyedDbRun("INSERT INTO foo VALUES('Lorem Ipsum', 1)")
.then(function(result) {
assert.deepEqual(result, {
changes: 1,
lastID: 1,
sql: "INSERT INTO foo VALUES('Lorem Ipsum', 1)"
});
done();
})
.catch(done);
assert.equal(result.changes, 1);
assert.equal(result.lastID, 1);
});
});

it('should update a value with placeholders', function(done) {
promisifyedDbRun("UPDATE foo SET txt = $text WHERE num = $id", {
it('should update a value with placeholders', function() {
return promisifyedDbRun("UPDATE foo SET txt = $text WHERE num = $id", {
$id: 1,
$text: "Dolor Sit Amet"
})
.then(function(result) {
assert.deepEqual(result, {
changes: 1,
lastID: 1,
sql: 'UPDATE foo SET txt = $text WHERE num = $id'
});
done();
})
.catch(done);
assert.equal(result.changes, 1);
assert.equal(result.lastID, 1);
});
});

it('should retrieve values', function(done) {
Expand Down

0 comments on commit 3d3faaa

Please sign in to comment.