Skip to content
Permalink
9c719d9158
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
68 lines (50 sloc) 1.18 KB
'use strict'
/* eslint-disable no-magic-numbers */
const todo = require('../modules/todo')
describe('add', () => {
beforeEach( () => todo.add('bread', 1))
afterEach( () => todo.clear())
test('check there is a single item', done => {
expect.assertions(1)
const items = todo.getAll()
expect(items.length).toBe(1)
done()
})
})
describe('clear', () => {
test('clear list with items', done => {
expect.assertions(1)
todo.add('bread', 1)
todo.add('butter', 2)
todo.clear()
const items = todo.getAll()
expect(items.length).toBe(0)
done()
})
test('clearing empty list should throw error', () => {
expect.assertions(1)
try {
todo.clear()
} catch(err) {
expect(err.message).toBe('trying to clear empty list')
}
})
})
describe('add', () => {
afterEach( () => todo.clear())
test('adding a single item', () => {
expect.assertions(1)
todo.add('bread', 1)
const items = todo.getAll()
expect(items.length).toBe(1)
})
})
describe('getAll', () => {
test('retrieving a single item', () => {
expect.assertions(2)
todo.add('bread', 1)
const items = todo.getAll()
expect(Array.isArray(items)).toBeTruthy()
expect(items.length).toBe(1)
})
})