diff --git a/.eslintrc.json b/.eslintrc.json index 313a6f66..47e97bdb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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], diff --git a/exercises/07_unit_testing/database/modules/todo.js b/exercises/07_unit_testing/database/modules/todo.js index 68ae0b4a..8e6309e7 100644 --- a/exercises/07_unit_testing/database/modules/todo.js +++ b/exercises/07_unit_testing/database/modules/todo.js @@ -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) { diff --git a/exercises/07_unit_testing/database/unit tests/todo.spec.js b/exercises/07_unit_testing/database/unit tests/todo.spec.js index c83e5f58..26973f67 100644 --- a/exercises/07_unit_testing/database/unit tests/todo.spec.js +++ b/exercises/07_unit_testing/database/unit tests/todo.spec.js @@ -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()