mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
update: enable api client test again
This commit is contained in:
parent
7c8adea941
commit
0afc64c5e9
1 changed files with 0 additions and 0 deletions
|
|
@ -1,94 +0,0 @@
|
|||
import test from 'ava'
|
||||
|
||||
import {
|
||||
generateAPI
|
||||
} from '~/helpers/api/client.js'
|
||||
|
||||
import {
|
||||
isString
|
||||
} from '~/helpers/check-types.js'
|
||||
|
||||
const listingsCases = [
|
||||
|
||||
// Spotify
|
||||
[
|
||||
'/api/app/spotify.json',
|
||||
{
|
||||
generateOptions: {},
|
||||
method: DoesItAPI => DoesItAPI.app.spotify,
|
||||
expected: {
|
||||
name: 'Spotify',
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// Electron
|
||||
[
|
||||
'/api/app/electron-framework.json',
|
||||
{
|
||||
generateOptions: {},
|
||||
method: DoesItAPI => DoesItAPI.app('electron-framework'),
|
||||
expected: { name: 'Electron Framework' }
|
||||
}
|
||||
],
|
||||
|
||||
// Express VPN
|
||||
[
|
||||
'/api/app/expressvpn.json',
|
||||
{
|
||||
generateOptions: {},
|
||||
method: DoesItAPI => DoesItAPI.app.expressvpn,
|
||||
expected: { name: 'ExpressVPN' }
|
||||
}
|
||||
],
|
||||
|
||||
// Solo App URL
|
||||
[
|
||||
'/api/app/solo.json',
|
||||
{
|
||||
generateOptions: {},
|
||||
method: DoesItAPI => DoesItAPI.app('solo'),
|
||||
expected: { name: 'SOLO' }
|
||||
}
|
||||
],
|
||||
|
||||
// Page 2 of App Kinds
|
||||
[
|
||||
'/api/kind/app/2.json',
|
||||
{
|
||||
generateOptions: {},
|
||||
method: DoesItAPI => DoesItAPI('kind/app')(2),
|
||||
expected: result => isString( result.nextPage )
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
test( 'API has valid responses', async t => {
|
||||
// const { listingsDetails } = t.context
|
||||
|
||||
for ( const [ caseEndpoint, listingCase ] of listingsCases ) {
|
||||
|
||||
// const apiPath = listingsDetails[ caseEndpoint ].apiEndpointPath
|
||||
|
||||
const DoesItAPI = generateAPI( listingCase.generateOptions )
|
||||
|
||||
const apiMethod = listingCase.method( DoesItAPI )
|
||||
|
||||
// Assert that the apiMethod url is correct
|
||||
t.is( (new URL(apiMethod.url)).pathname, caseEndpoint, `API endpoint '${ caseEndpoint }'` )
|
||||
|
||||
// Run get request to fetch our data
|
||||
const result = await apiMethod.get()
|
||||
|
||||
// If expected is a function then call it
|
||||
// Otherwise, compare the result to the expected
|
||||
if ( typeof listingCase.expected === 'function' ) {
|
||||
t.assert( listingCase.expected( result ), `API case method check for '${ caseEndpoint }'` )
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
t.like( result, listingCase.expected, `${ caseEndpoint } has a valid api endpoint` )
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue