mirror of
https://github.com/ershisan99/it-incubator-todolist-ts-17-live-2024-08-17.git
synced 2025-12-16 20:59:30 +00:00
28 lines
913 B
TypeScript
28 lines
913 B
TypeScript
import {addTodolistAC, TodolistDomainType, todolistsReducer} from './todolists-reducer'
|
|
import {tasksReducer, TasksStateType} from './tasks-reducer'
|
|
import {TodolistType} from '../../api/todolists-api'
|
|
|
|
test('ids should be equals', () => {
|
|
const startTasksState: TasksStateType = {};
|
|
const startTodolistsState: Array<TodolistDomainType> = [];
|
|
|
|
let todolist: TodolistType = {
|
|
title: 'new todolist',
|
|
id: 'any id',
|
|
addedDate: '',
|
|
order: 0
|
|
}
|
|
|
|
const action = addTodolistAC(todolist);
|
|
|
|
const endTasksState = tasksReducer(startTasksState, action)
|
|
const endTodolistsState = todolistsReducer(startTodolistsState, action)
|
|
|
|
const keys = Object.keys(endTasksState);
|
|
const idFromTasks = keys[0];
|
|
const idFromTodolists = endTodolistsState[0].id;
|
|
|
|
expect(idFromTasks).toBe(action.todolist.id);
|
|
expect(idFromTodolists).toBe(action.todolist.id);
|
|
});
|