The configured setup will be applied or not accordingly to the value in the sequence.

Example


const value = 'value';
const object = new Mock<Function>()
.setup(instance => instance(1))
.play(PlayTimes.Sequence([false, true]))
.returns(value)
.object();

expect(object(1).toBe(undefined);
expect(object(1).toBe(value);
expect(object(1).toBe(undefined);

Hierarchy

  • PlayableSequence

Implements

Constructors

Methods

Constructors

Methods

  • Invokes as the setup is about to be played, so the playable logic can change it's state.

    Example


    const playable1 = new PlayableOnce();
    const playable2 = new PlayableOnce();

    const mock = new Mock<(val: number) => void)>()
    // setup A
    .setup(instance => instance(1))
    .play(playable1)
    .returns(1)
    // setup B
    .setup(instance => instance(2))
    .play(playable2)
    .returns(2);

    const actual = mock.object()(1);
    // at this point the update of playable1 should be called with OwnSetupWouldBePlayed
    // because setup A would be played
    // and the update of playable2 should be called with OtherSetupWouldBePlayed

    Returns void

Generated using TypeDoc