Skip to content

Commit

Permalink
fix ui testing
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Jan 24, 2024
1 parent 570d567 commit 150160e
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions ui/artalk/tests/ui-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,28 @@ beforeAll(() => {
ok: true,
status: 200,
json: () => {
const resp = {
success: true,
data: {}
}
let resp: any = {}

const map = {
'/api/v2/conf': {
frontend_conf: RemoteConf,
version: {},
},
'/api/v2/stat': { '/': 0 },
'/api/v2/pv': { pv: 2 },
'/api/v2/stat': { data: { '/': 0 } },
'/api/v2/pages/pv': { pv: 2 },
'/api/v2/notifies': { notifies: [], count: 0 },
'/api/v2/comments': {
comments: [],
total: 0,
total_roots: 0,
count: 0,
roots_count: 0,
page: { id: 4, admin_only: false, key: '/', url: '/', title: 'Artalk DEMO', site_name: 'ArtalkDocs', vote_up: 0, vote_down: 0, pv: 1 },
unread: [],
unread_count: 0,
conf: { frontend_conf: {}, version: {} },
}
}

const path = new URL(url).pathname

Object.entries(map).forEach(([k, v]) => {
if (url.endsWith(k)) resp.data = v
if (path.startsWith(k)) resp = v
})

return Promise.resolve(resp)
Expand Down

0 comments on commit 150160e

Please sign in to comment.