| 12345678910111213141516171819202122232425 |
- /* eslint-env jest */
- import request from '@/utils/request'
- import { fetchGuestProducts, fetchGuestCart, createGuestOrder } from '@/api/shop'
- import { getGuestRegionList, getRegionList } from '@/api/config'
- jest.mock('@/utils/request', () => jest.fn())
- it.each([[fetchGuestProducts, '/v1/shop/no-login-reconsume'], [fetchGuestCart, '/v1/shop/no-login-show-cart']])('calls the anonymous GET endpoint without modifying the country ID', (api, url) => {
- const params = { countryId: '620699181539139643' }
- api(params)
- expect(request).toHaveBeenLastCalledWith({ url, method: 'get', params })
- })
- it('posts the guest order to its own endpoint', () => {
- const data = { countryId: '620699181539139643', goodsId: ['P1'], goodsNum: [1] }
- createGuestOrder(data)
- expect(request).toHaveBeenLastCalledWith({ url: '/v1/shop/no-login-reconsume-sure-order', method: 'post', data })
- })
- it.each(['620699181539139625', '620699181539139643'])('queries anonymous regions with countryId %s', countryId => {
- const params = { countryId }
- getGuestRegionList(params)
- expect(request).toHaveBeenLastCalledWith({ url: '/v1/config/no-login-region-list', method: 'get', params })
- })
- it('keeps member region queries on the original endpoint', () => {
- const params = { countryId: '620699181539139625' }
- getRegionList(params)
- expect(request).toHaveBeenLastCalledWith({ url: '/v1/config/region-list', method: 'get', params })
- })
|