aslan-admin/tests/unit/views/rocket-config.spec.js

46 lines
1.3 KiB
JavaScript

import Vue from 'vue'
import { shallowMount } from '@vue/test-utils'
import RocketConfig from '@/views/rocket/config/index.vue'
jest.mock('@/api/rocket-config', () => ({
listRocketConfigs: jest.fn(() => Promise.resolve({ body: [] })),
updateRocketConfig: jest.fn(() => Promise.resolve({}))
}))
describe('RocketConfig edit dialog', () => {
const originalSilent = Vue.config.silent
beforeAll(() => {
Vue.config.silent = true
})
afterAll(() => {
Vue.config.silent = originalSilent
})
const createWrapper = () => shallowMount(RocketConfig, {
mocks: {
$t: key => key,
$message: { warning: jest.fn() },
$opsMessage: { success: jest.fn() }
}
})
it('keeps the dialog above the mask and allows adding an empty reward', async() => {
const wrapper = createWrapper()
const dialog = wrapper.find('el-dialog')
expect(dialog.attributes('append-to-body')).toBe('true')
expect(dialog.attributes('modal-append-to-body')).toBe('true')
wrapper.vm.dialogVisible = true
wrapper.vm.addReward()
await wrapper.vm.$nextTick()
expect(wrapper.vm.dialogVisible).toBe(true)
expect(wrapper.vm.form.rewardConfig).toHaveLength(1)
expect(wrapper.vm.form.rewardConfig[0].type).toBe('GOLD')
expect(wrapper.find('.rocket-dialog-content').exists()).toBe(true)
})
})