Skip to content
Permalink
Browse files
added comments
  • Loading branch information
aa7401 committed Sep 14, 2019
1 parent c665bb2 commit e886bde3fb047f93ab92a525df59f45cb55b4023
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
@@ -27,7 +27,7 @@
"max-depth": ["error", 3],
"max-len": ["warn", { "code": 120, "tabWidth": 4 }],
"max-lines": ["error", 100],
"max-lines-per-function": ["error", 15],
"max-lines-per-function": ["error", 20],
"max-nested-callbacks": ["error", 4],
"max-params": ["error", 5],
"max-statements": ["error", 20],
@@ -18,7 +18,7 @@ module.exports = class ToDo {
qty = Number(qty)
if(isNaN(qty)) throw new Error('the quantity must be a number')
let sql = 'SELECT * FROM items;'
const dataAll = await this.db.all(sql)
// const dataAll = await this.db.all(sql)
sql = `SELECT * FROM items WHERE ITEM = "${item}"`
const data = await this.db.all(sql)
if(data.length === 0) {
@@ -22,9 +22,12 @@ describe('add()', () => {
test('add a single item', async done => {
expect.assertions(1)
try {
// ARRANGE
const todo = await new ToDo() // DB runs in-memory if no name supplied
// ACT
await todo.add('bread', 3)
const count = await todo.countItems()
// ASSERT
expect(count).toBe(1)
} catch(err) {
done.fail(err)
@@ -36,10 +39,13 @@ describe('add()', () => {
test('qty must be a number', async done => {
expect.assertions(1)
try {
// ARRANGE
const todo = await new ToDo()
// ACT
await todo.add('bread', 'three')
done.fail('test failed')
} catch(err) {
// ASSERT
expect(err.message).toBe('the quantity must be a number')
} finally {
done()

0 comments on commit e886bde

Please sign in to comment.