From 3394a004197f0521082991b9f3f3797cfd8e6505 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Fri, 15 Oct 2021 10:41:31 -0400 Subject: [PATCH] test with ts --- src/mutations.test.js | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/mutations.test.js b/src/mutations.test.js index e7ce90c..8a09503 100644 --- a/src/mutations.test.js +++ b/src/mutations.test.js @@ -1,9 +1,7 @@ -import { test } from 'tap'; +import { Updux } from './Updux'; +import { action } from './actions'; -import { Updux } from './Updux.js'; -import { action } from './actions.js'; - -test('basic', async (t) => { +test('basic', () => { const doIt = action('doIt'); const thisToo = action('thisToo'); @@ -16,12 +14,12 @@ test('basic', async (t) => { }, }); - t.equal(dux.reducer(undefined, dux.actions.doIt()), 'bingo'); + expect(dux.reducer(undefined, dux.actions.doIt())).toEqual( 'bingo'); - t.equal(dux.reducer(undefined, dux.actions.thisToo()), 'straight type'); + expect(dux.reducer(undefined, dux.actions.thisToo())).toEqual( 'straight type'); }); -test('override', async (t) => { +test('override', () => { const foo = action('foo'); const dux = new Updux({ @@ -50,13 +48,14 @@ test('override', async (t) => { undefined ); - t.match(state, { + expect(state).toMatchObject( + { alpha: ['foo', 'bar'], subbie: 1, }); }); -test('order of processing', async (t) => { +test('order of processing', () => { const foo = action('foo'); const dux = new Updux({ @@ -78,26 +77,33 @@ test('order of processing', async (t) => { }, }); - t.same(dux.reducer(undefined, foo()), { x: ['subdux', 'main'] }); + expect(dux.reducer(undefined, foo())) + .toMatchObject({ x: ['subdux', 'main'] }); }); -test('setMutation', async (t) => { +test('setMutation', () => { const foo = action('foo'); const dux = new Updux({ initial: '', }); - t.equal(dux.reducer(undefined, foo()), '', 'noop'); + // noop + expect(dux.reducer(undefined, foo())).toEqual( ''); dux.setMutation('foo', () => () => 'foo'); - t.equal(dux.reducer(undefined, foo()), 'foo', 'foo was added'); + expect(dux.reducer(undefined, foo())).toEqual( 'foo'); - await t.test('name as function', async (t) => { +}); + +test('setMutation, name as function', () => { const bar = action('bar'); + + const dux = new Updux({ + initial: '', + }); dux.setMutation(bar, () => () => 'bar'); - t.equal(dux.reducer(undefined, bar()), 'bar', 'bar was added'); + expect(dux.reducer(undefined, bar())).toEqual( 'bar'); }); -});