Skip to content
Permalink
Browse files
worked on mocks exercise
  • Loading branch information
aa7401 committed Nov 14, 2018
1 parent 0e2f737 commit 56bad10669017a9c32ab882215abbd1f2985f0cc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
@@ -74,7 +74,7 @@ This week you are starting the development process. You are advised to use the `
5. Add a `.eslintignore` file containing the files and directories you want to be ignored by the linter.
6. Add a jest section to your `package.json` that includes the coverage thresholds you are aiming for (100%).
7. Create a `pre-commit` file in the `.git/hooks/` directory:
1. Add a _shebang.
1. Add a _shebang. If you are on Windows this will be `#!C:/Program\ Files/Git/usr/bin/sh.exe`, on Mac or Linux it is `#!/bin/sh`.
2. Add the line `echo "pre-commit hook working"`.
3. Make the file executable.
8. Create a `README.md` file and add the name of your project.
@@ -10,7 +10,9 @@ module.exports.init = () => {

module.exports.setItem = async(key, val) => {
const item = {item: key, qty: val}
console.log(item)
items.push(item)
console.log(items)
return
}

@@ -31,7 +33,9 @@ module.exports.removeItem = async key => {
}

module.exports.forEach = async callback => {
console.log(items)
for (const i in items) {
console.log(items[i].qty)
await callback(items[i].qty)
}
}
@@ -52,6 +52,7 @@ describe('getAll', () => {
const request = {body: { item: 'bread', qty: 5 }}
await todo.add(request)
const data = await todo.getAll()
console.log(data)
expect(Array.isArray(data)).toBeTruthy()
expect(data.length).toBe(1)
expect(data[0].item).toBe('bread')
@@ -12,6 +12,7 @@ init()

module.exports.add = async request => {
const data = await this.extractBodyData(request)
console.log(data)
await persist.setItem(data.item, data.qty)
return data
}
@@ -24,7 +25,11 @@ module.exports.getResource = async resource => {

module.exports.getAll = async() => {
const data = []
await persist.forEach(async datum => data.push({item: datum.key, qty: datum.value}))
await persist.forEach(async datum => {
console.log(datum)
data.push({item: datum.key, qty: datum.value})
})
console.log(data)
return data
}

0 comments on commit 56bad10

Please sign in to comment.