Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aa7401 committed Sep 14, 2019
1 parent c665bb2 commit e886bde
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion exercises/07_unit_testing/database/modules/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions exercises/07_unit_testing/database/unit tests/todo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit e886bde

Please sign in to comment.