You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.6 KiB
76 lines
2.6 KiB
import { createLocalVue, shallowMount } from '@vue/test-utils'
|
|
import ElementUI from 'element-ui'
|
|
import BudgetReviewIndex from '@/views/budget/review/index.vue'
|
|
import BudgetReviewDetail from '@/views/budget/review/components/BudgetReviewDetail.vue'
|
|
import { getBudgetReviewDetail } from '@/api/budget/budgetReview'
|
|
|
|
const localVue = createLocalVue()
|
|
localVue.use(ElementUI)
|
|
|
|
jest.mock('@/api/budget/budgetCollectionYear.js', () => ({
|
|
getBudgetCollectionYearOptions: jest.fn(() => Promise.resolve([]))
|
|
}))
|
|
|
|
jest.mock('@/api/budget/budgetReview.js', () => ({
|
|
getBudgetReviews: jest.fn(() => Promise.resolve({ items: [], page: 1, total: 0 })),
|
|
getBudgetReviewDetail: jest.fn(),
|
|
reviewBudgetSubmission: jest.fn(),
|
|
batchReviewBudgetSubmissions: jest.fn(),
|
|
getBudgetReviewStatistics: jest.fn()
|
|
}))
|
|
|
|
describe('leader budget review', () => {
|
|
const message = {
|
|
error: jest.fn(),
|
|
success: jest.fn(),
|
|
warning: jest.fn()
|
|
}
|
|
|
|
beforeEach(() => jest.clearAllMocks())
|
|
|
|
it('loads the dedicated detail endpoint with the submission id', async() => {
|
|
const detail = {
|
|
submission: { id: 8, status: 'submitted', economic_items: [], performance_indicators: [] },
|
|
departmentSummary: []
|
|
}
|
|
getBudgetReviewDetail.mockResolvedValue(detail)
|
|
const wrapper = shallowMount(BudgetReviewIndex, {
|
|
localVue,
|
|
mocks: { $message: message }
|
|
})
|
|
|
|
await wrapper.vm.viewDetail({ id: 8, package_id: 12 })
|
|
|
|
expect(getBudgetReviewDetail).toHaveBeenCalledWith(8)
|
|
expect(wrapper.vm.currentReviewData).toEqual(detail)
|
|
expect(wrapper.vm.detailDialogVisible).toBe(true)
|
|
})
|
|
|
|
it('keeps lead and department submission details in one view model', () => {
|
|
const submissionData = {
|
|
submission: {
|
|
id: 8,
|
|
status: 'submitted',
|
|
economic_items: [{ amount: '0.0001' }],
|
|
performance_indicators: [{ level3: '预算执行率' }]
|
|
},
|
|
departmentSummary: [{
|
|
id: 31,
|
|
departmentName: '执行科室',
|
|
allocatedAmount: '0.0001',
|
|
status: 'approved',
|
|
submission: {
|
|
economic_items: [{ amount: '0.0001' }],
|
|
performance_indicators: [{ level3: '预算执行率' }]
|
|
}
|
|
}]
|
|
}
|
|
const wrapper = shallowMount(BudgetReviewDetail, { localVue, propsData: { submissionData }})
|
|
|
|
expect(wrapper.vm.economicItems).toEqual(submissionData.submission.economic_items)
|
|
expect(wrapper.vm.performanceIndicators).toEqual(submissionData.submission.performance_indicators)
|
|
expect(wrapper.props('submissionData').departmentSummary[0].submission.economic_items).toHaveLength(1)
|
|
expect(wrapper.vm.formatCurrency('0.0001')).toBe('0.0001')
|
|
})
|
|
})
|