import { test, expect } from 'vitest'; import { action } from './actions.js'; import { Updux } from './Updux.js'; test('basic action', () => { const foo = action('foo', (thing) => ({ thing })); expect(foo('bar')).toEqual({ type: 'foo', payload: { thing: 'bar', }, }); }); test( "Updux config accepts actions", () => { const foo = new Updux({ actions: { one: action('one', (x) => ({x})), two: action('two', x => x), } }); expect(Object.keys(foo.actions)).toHaveLength(2); expect( foo.actions.one ).toBeTypeOf('function'); expect( foo.actions.one("potato") ).toEqual({ type: 'one', payload: { x: 'potato' } }); } )