First green test

This commit is contained in:
Angelina Filippova 2020-09-08 17:24:37 +03:00
parent 14a46f7719
commit e1b9ccdef1
3 changed files with 81 additions and 0 deletions

View 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) {
}

View 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()
})
})

View 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
}