All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ducks.toolbar.__tests__.sagas.test.js Maven / Gradle / Ivy

The newest version!
import {
    changeButtonVisibility,
    changeButtonMessage,
    changeButtonDisabled,
} from '../store'
import {
    resolveButton,
} from '../sagas'

const setupResolveButton = () => resolveButton({
    conditions: {
        visible: [
            {
                expression: 'test === \'test\'',
                modelLink: 'model',
            },
        ],
        enabled: [
            {
                expression: 'test !== \'test\'',
                modelLink: 'model',
                message: 'test message',
            },
        ],
    },
})

describe('Проверка саги toolbar', () => {
    it('Тестирование вызова  экшена на саге', () => {
        const gen = setupResolveButton()

        gen.next()
        let { value } = gen.next({ model: { test: 'test' } })

        expect(value.payload.action.type).toEqual(changeButtonVisibility.type)
        expect(value.payload.action.payload.visible).toBe(true)
        gen.next()
        value = gen.next().value
        expect(value.payload.action.type).toEqual(changeButtonDisabled.type)
        expect(value.payload.action.payload.disabled).toBe(true)
        value = gen.next().value
        expect(value.payload.action.type).toEqual(changeButtonMessage.type)
        expect(value.payload.action.payload.message).toBe('test message')
        gen.next()
        expect(gen.next().done).toBe(true)
    })
})




© 2015 - 2024 Weber Informatics LLC | Privacy Policy