generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from iLynette/testing
Testing
- Loading branch information
Showing
8 changed files
with
1,651 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"env": { | ||
"test": { | ||
"plugins": ["@babel/plugin-transform-modules-commonjs"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import _ from 'lodash'; //eslint-disable-line | ||
import './style.css'; | ||
import gin from './modules/utils.js'; | ||
import * as gin from './modules/utils.js'; | ||
|
||
gin(); | ||
gin.genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import TodoList from './src/modules/todoList.js'; | ||
import * as gin from './src/modules/utils.js'; | ||
|
||
class LocalStorageMock { | ||
constructor() { | ||
this.store = {}; | ||
} | ||
|
||
clear() { | ||
this.store = {}; | ||
} | ||
|
||
getItem(key) { | ||
return this.store[key] || null; | ||
} | ||
|
||
setItem(key, value) { | ||
this.store[key] = String(value); | ||
} | ||
|
||
removeItem(key) { | ||
delete this.store[key]; | ||
} | ||
} | ||
|
||
global.localStorage = new LocalStorageMock(); | ||
|
||
document.body.innerHTML = `<div> + | ||
<div id="dynamic-list"></div> | ||
</div>`; | ||
const todoList = new TodoList(); | ||
|
||
describe('Add task', () => { | ||
test('Add one task expect tasks length to be 1', () => { | ||
todoList.addTodo('go shopping'); | ||
todoList.addTodo('watch a movie'); | ||
expect(todoList.todos.length).toBe(2); | ||
}); | ||
}); | ||
|
||
describe('Add the added todo to the DOM', () => { | ||
test('One task has been added expect one task element in DOM', () => { | ||
gin.allTasks(todoList); | ||
const tasksList = document.getElementById('dynamic-list'); | ||
expect(tasksList.childNodes.length).toBe(2); | ||
}); | ||
}); | ||
|
||
describe('Remove first todo from todoList', () => { | ||
test('One task has been remove expect zero', () => { | ||
const { id } = todoList.todos[0]; | ||
const taskCard = document.getElementById(id); | ||
taskCard.parentNode.removeChild(taskCard); | ||
expect(todoList.delete(id)).toBe(id); | ||
}); | ||
}); | ||
|
||
describe('Check if task card had been removed from DOM', () => { | ||
test('One card removed expect node children to be 0', () => { | ||
const tasksList = document.getElementById('dynamic-list'); | ||
expect(tasksList.childNodes.length).toBe(1); | ||
}); | ||
}); |