First green test
This commit is contained in:
parent
14a46f7719
commit
e1b9ccdef1
3 changed files with 81 additions and 0 deletions
20
src/api/__mocks__/mediaProxyCache.js
Normal file
20
src/api/__mocks__/mediaProxyCache.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
const urls = [
|
||||
'http://example.com/media/a688346.jpg',
|
||||
'http://example.com/media/fb1f4d.jpg'
|
||||
]
|
||||
|
||||
export async function listBannedUrls(page, pageSize, authHost, token) {
|
||||
return Promise.resolve({ data: { page_size: 1, count: 2, urls }})
|
||||
}
|
||||
|
||||
export async function purgeUrls(urls, ban, authHost, token) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
export async function removeBannedUrls(urls, authHost, token) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
export async function searchBannedUrls(query, page, pageSize, authHost, token) {
|
||||
|
||||
}
|
40
test/views/mediaProxyCache/index.test.js
Normal file
40
test/views/mediaProxyCache/index.test.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
import Vuex from 'vuex'
|
||||
import { mount, createLocalVue, config } from '@vue/test-utils'
|
||||
import flushPromises from 'flush-promises'
|
||||
import Element from 'element-ui'
|
||||
import MediaProxyCache from '@/views/mediaProxyCache/index'
|
||||
import storeConfig from './store.conf'
|
||||
import { cloneDeep } from 'lodash'
|
||||
|
||||
config.mocks["$t"] = () => {}
|
||||
|
||||
const localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
localVue.use(Element)
|
||||
|
||||
jest.mock('@/api/app')
|
||||
jest.mock('@/api/nodeInfo')
|
||||
jest.mock('@/api/mediaProxyCache')
|
||||
jest.mock('@/api/settings')
|
||||
|
||||
describe('', () => {
|
||||
let store
|
||||
|
||||
beforeEach(() => {
|
||||
store = new Vuex.Store(cloneDeep(storeConfig))
|
||||
})
|
||||
|
||||
it('fetches initial list of urls', async (done) => {
|
||||
const wrapper = mount(MediaProxyCache, {
|
||||
store,
|
||||
localVue,
|
||||
sync: false
|
||||
})
|
||||
|
||||
await flushPromises()
|
||||
console.log(store.state)
|
||||
console.log(wrapper.html())
|
||||
expect(wrapper.vm.urlsCount).toEqual(2)
|
||||
done()
|
||||
})
|
||||
})
|
21
test/views/mediaProxyCache/store.conf.js
Normal file
21
test/views/mediaProxyCache/store.conf.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import app from '@/store/modules/app'
|
||||
import mediaProxyCache from '@/store/modules/mediaProxyCache'
|
||||
import user from '@/store/modules/user'
|
||||
import users from '@/store/modules/users'
|
||||
import reports from '@/store/modules/reports'
|
||||
import settings from '@/store/modules/settings'
|
||||
import status from '@/store/modules/status'
|
||||
import getters from '@/store/getters'
|
||||
|
||||
export default {
|
||||
modules: {
|
||||
app,
|
||||
mediaProxyCache,
|
||||
user,
|
||||
users,
|
||||
reports,
|
||||
settings,
|
||||
status
|
||||
},
|
||||
getters
|
||||
}
|
Loading…
Reference in a new issue