updux/dist/tutorial/final.test.js

31 lines
877 B
JavaScript
Raw Normal View History

2025-01-31 18:16:41 +00:00
import { test, expect } from 'vitest';
import todoListDux from './todoList.js';
test('basic', () => {
const store = todoListDux.createStore();
store.dispatch.addTodo('write tutorial');
store.dispatch.addTodo('test code snippets');
store.dispatch.todoDone(2);
const s = store.getState();
expectTypeOf(s).toMatchTypeOf();
expect(store.getState()).toMatchObject({
todos: [
{ id: 1, done: false },
{ id: 2, done: true },
],
});
// expect(todoListDux.schema).toMatchObject({
// type: 'object',
// properties: {
// nextId: { type: 'number', default: 1 },
// todos: {
// default: [],
// type: 'array',
// }
// },
// default: {
// nextId: 1,
// todos: [],
// },
// });
});