From 46b0565819e08cd73ea7c15689c42c82c0f7e21c Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Thu, 25 Aug 2022 11:51:53 -0400 Subject: [PATCH] add reducer --- src/Updux.ts | 4 ++++ src/reducer.test.ts | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/reducer.test.ts diff --git a/src/Updux.ts b/src/Updux.ts index 5527ab2..ffa5084 100644 --- a/src/Updux.ts +++ b/src/Updux.ts @@ -50,4 +50,8 @@ export class Updux initial), ); } + + get reducer() { + return (state, action) => state; + } } diff --git a/src/reducer.test.ts b/src/reducer.test.ts new file mode 100644 index 0000000..82a1e15 --- /dev/null +++ b/src/reducer.test.ts @@ -0,0 +1,11 @@ +import { test, expect } from 'vitest'; + +import { Updux } from './Updux.js'; + +test('basic reducer', () => { + const dux = new Updux({}); + + expect(dux.reducer).toBeTypeOf('function'); + + expect(dux.reducer({ a: 1 }, { type: 'foo' })).toMatchObject({ a: 1 }); // noop +});