Skip to content

Commit

Permalink
Use test.each for more semantic vitest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amcaplan committed Nov 24, 2024
1 parent b09181d commit db183b7
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ describe('versionDeepLink', () => {
})

describe('searching for apps', () => {
async function appSearchTest({query, queryVariable}: {query?: string; queryVariable: string}) {
test.each([
['without a term if none is provided', undefined, ''],
['without a term if a blank string is provided', '', ''],
['with a single term passed in the query', 'test-app', 'title:test-app'],
['with multiple terms passed in the query', 'test app', 'title:test title:app'],
])('searches for apps by name %s', async (_: string, query: string | undefined, queryVariable: string) => {
// Given
const orgId = '1'
const appName = 'test-app'
Expand Down Expand Up @@ -235,17 +240,5 @@ describe('searching for apps', () => {
})),
hasMorePages: false,
})
}

test('passes in a blank search if none is provided', async () => {
await appSearchTest({query: undefined, queryVariable: ''})
})

test('searches for apps by name with a single term passed in the query', async () => {
await appSearchTest({query: 'test-app', queryVariable: 'title:test-app'})
})

test('searches for apps by name with multiple terms passes in the query', async () => {
await appSearchTest({query: 'test app', queryVariable: 'title:test title:app'})
})
})

0 comments on commit db183b7

Please sign in to comment.