Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing To Do list: part 1 #6

Merged
merged 5 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"env": {
"test": {
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
coverage
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Project Name

> This is a projec to track your daily tasks as a todo list. This project doesn't have a backend so data gets saved in you local storage.
> This is a project to track your daily tasks as a todo list. This project doesn't have a backend so data gets saved in you local storage.


## Built With
Expand All @@ -26,6 +26,10 @@

- Run ``` npm install ```

## Extra configuration for testing

- Run ``` npm test```

## Authors

👤 **Ritobroto Mukherjee**
Expand All @@ -36,6 +40,11 @@
- LinkedIn: [Ritobroto Mukherjee](https://www.linkedin.com/in/ritobroto-mukherjee-519148ba/)


👤 **Divine Charlotte**

- GitHub: [@divinecharlotte](https://github.com/divinecharlotte)
- LinkedIn: [Divine Charlotte](https://www.linkedin.com/in/charlotte-divine-dusenge-31b19017a/)

## 🤝 Contributing

Contributions, issues, and feature requests are welcome!
Expand Down
44 changes: 44 additions & 0 deletions __test__/addDelete.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint-disable */

import crud from '../src/js/CRUD';
import TaskList from '../src/js/taskList';

// super class mock initiate
jest.mock('../src/js/taskList');

describe('add and delete 1-1 to-do item', () => {
const c = new crud();
const toDoList = [];
c.tasks = toDoList;

// mock the localStorage setList function
const mockSetList = jest.fn((tasks) => toDoList = JSON.stringify(tasks));

TaskList.mockImplementation(() => {
return{
setList: mockSetList,
}

});
test('To-Do Add 1 task', () => {
// Arrange
const previousTasksCount = c.tasks.length;

// ACT
const afterAddTasksCount = c.addTask('Go to gym');

// Assert
expect(afterAddTasksCount.length).toBe(previousTasksCount + 1);
});

test('To-Do Delete 1 task', () => {
// Arrange
const previousTasksCount = c.tasks.length;

// Act
const afterRemoveTasksArray = c.removeTask(0);

// Assert
expect(previousTasksCount).toBe(afterRemoveTasksArray.length + 1);
});
});
12 changes: 6 additions & 6 deletions dist/build.js

Large diffs are not rendered by default.