mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add test cases
This commit is contained in:
parent
46f3515698
commit
7c56dc2cba
1 changed files with 48 additions and 0 deletions
|
|
@ -1195,6 +1195,54 @@ describe('Article API', () => {
|
|||
})
|
||||
})
|
||||
|
||||
context('when wildcard search for labels', () => {
|
||||
let items: LibraryItem[] = []
|
||||
let labelIds: string[]
|
||||
|
||||
before(async () => {
|
||||
keyword = 'label:test/*'
|
||||
// Create some test items
|
||||
const label1 = await createLabel('test/one', '', user.id)
|
||||
const label2 = await createLabel('test/two', '', user.id)
|
||||
labelIds = [label1.id, label2.id]
|
||||
|
||||
items = await createLibraryItems(
|
||||
[
|
||||
{
|
||||
user,
|
||||
title: 'test title wildcard',
|
||||
readableContent: '<p>test wildcard</p>',
|
||||
slug: 'test slug wildcard',
|
||||
originalUrl: `${url}/wildcard`,
|
||||
},
|
||||
{
|
||||
user,
|
||||
title: 'test title wildcard 1',
|
||||
readableContent: '<p>test wildcard</p>',
|
||||
slug: 'test slug wildcard 1',
|
||||
originalUrl: `${url}/wildcard_1`,
|
||||
},
|
||||
],
|
||||
user.id
|
||||
)
|
||||
await saveLabelsInLibraryItem([label1], items[0].id, user.id)
|
||||
await saveLabelsInLibraryItem([label2], items[1].id, user.id)
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await deleteLabels(labelIds, user.id)
|
||||
await deleteLibraryItems(items, user.id)
|
||||
})
|
||||
|
||||
it('returns library items with label test/one and test/two', async () => {
|
||||
const res = await graphqlRequest(query, authToken).expect(200)
|
||||
|
||||
expect(res.body.data.search.pageInfo.totalCount).to.eq(2)
|
||||
expect(res.body.data.search.edges[0].node.id).to.eq(items[0].id)
|
||||
expect(res.body.data.search.edges[1].node.id).to.eq(items[1].id)
|
||||
})
|
||||
})
|
||||
|
||||
context('when type:file label:test is in the query', () => {
|
||||
let items: LibraryItem[] = []
|
||||
let label: Label
|
||||
|
|
|
|||
Loading…
Reference in a new issue