updux/src/reducer.test.js

20 lines
520 B
JavaScript
Raw Normal View History

2022-08-25 15:51:53 +00:00
import { test, expect } from 'vitest';
import { Updux } from './Updux.js';
test('basic reducer', () => {
2022-08-26 00:06:52 +00:00
const dux = new Updux({ initial: { a: 3 } });
2022-08-25 15:51:53 +00:00
expect(dux.reducer).toBeTypeOf('function');
expect(dux.reducer({ a: 1 }, { type: 'foo' })).toMatchObject({ a: 1 }); // noop
});
2022-08-25 16:40:54 +00:00
test('basic upreducer', () => {
2022-08-26 00:06:52 +00:00
const dux = new Updux({ initial: { a: 3 } });
2022-08-25 16:40:54 +00:00
2022-08-25 21:52:13 +00:00
expect(dux.upreducer).toBeTypeOf('function');
2022-08-25 16:40:54 +00:00
2022-08-26 00:06:52 +00:00
expect(dux.upreducer({ type: 'foo' })({ a: 1 })).toMatchObject({ a: 1 }); // noop
2022-08-25 16:40:54 +00:00
});