import { Chain, Step } from '@ephox/agar';
import { Assert } from '@ephox/bedrock-client';
import { Optional } from '@ephox/katamari';
export const TestStore = () => {
    let array = [];
    const add = (value) => {
        array.push(value);
        // eslint-disable-next-line no-console
        console.log('store.add', value, array);
    };
    const adder = (value) => () => add(value);
    // Used for keyboard handlers which need to return Optional to know whether or not to kill the event
    const adderH = (value) => () => {
        add(value);
        return Optional.some(true);
    };
    const sClear = Step.sync(() => {
        array = [];
    });
    const clear = () => {
        array = [];
    };
    const cClear = Chain.op(() => {
        clear();
    });
    const sAssertEq = (label, expected) => Step.sync(() => 
    // Can't use a normal step here, because we don't need to get array lazily
    Assert.eq(label, expected, array.slice(0)));
    const cAssertEq = (label, expected) => Chain.op(() => {
        assertEq(label, expected);
    });
    const assertEq = (label, expected) => Assert.eq(label, expected, array.slice(0));
    const sAssertSortedEq = (label, expected) => Step.sync(() => 
    // Can't use a normal step here, because we don't need to get array lazily
    Assert.eq(label, expected.slice(0).sort(), array.slice(0).sort()));
    return {
        add,
        adder,
        adderH,
        clear,
        sClear,
        cClear,
        sAssertEq,
        cAssertEq,
        assertEq,
        sAssertSortedEq
    };
};
//# sourceMappingURL=TestStore.js.map