mirror of
https://github.com/BradNut/graphbrainz
synced 2025-09-08 17:40:32 +00:00
* Add a schema extension API and several extensions * Update graphql-markdown to use new diffSchema function * Update Node support
118 lines
2.7 KiB
JavaScript
118 lines
2.7 KiB
JavaScript
import test from 'ava'
|
|
import { graphql } from 'graphql'
|
|
import extension from '../../../src/extensions/the-audio-db'
|
|
import baseSchema, { applyExtension } from '../../../src/schema'
|
|
import baseContext from '../../helpers/context'
|
|
|
|
const schema = applyExtension(extension, baseSchema)
|
|
const context = extension.extendContext(baseContext)
|
|
|
|
function testData (t, query, handler) {
|
|
return graphql(schema, query, null, context).then(result => {
|
|
if (result.errors !== undefined) {
|
|
console.log(result.errors)
|
|
}
|
|
t.is(result.errors, undefined)
|
|
return handler(t, result.data)
|
|
})
|
|
}
|
|
|
|
test('artists have a theAudioDB field', testData, `
|
|
{
|
|
lookup {
|
|
artist(mbid: "5b11f4ce-a62d-471e-81fc-a69a8278c7da") {
|
|
theAudioDB {
|
|
artistID
|
|
biography
|
|
biographyJP: biography(lang: "jp")
|
|
memberCount
|
|
banner
|
|
bannerPreview: banner(size: PREVIEW)
|
|
fanArt
|
|
fanArtPreview: fanArt(size: PREVIEW)
|
|
logo
|
|
logoPreview: logo(size: PREVIEW)
|
|
thumbnail
|
|
thumbnailPreview: thumbnail(size: PREVIEW)
|
|
genre
|
|
mood
|
|
style
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`, (t, data) => {
|
|
t.snapshot(data)
|
|
})
|
|
|
|
test('release groups have a theAudioDB field', testData, `
|
|
{
|
|
lookup {
|
|
releaseGroup(mbid: "aa997ea0-2936-40bd-884d-3af8a0e064dc") {
|
|
theAudioDB {
|
|
albumID
|
|
artistID
|
|
description
|
|
descriptionES: description(lang: "es")
|
|
review
|
|
salesCount
|
|
score
|
|
scoreVotes
|
|
discImage
|
|
discImagePreview: discImage(size: PREVIEW)
|
|
spineImage
|
|
spineImagePreview: spineImage(size: PREVIEW)
|
|
frontImage
|
|
frontImagePreview: frontImage(size: PREVIEW)
|
|
backImage
|
|
backImagePreview: backImage(size: PREVIEW)
|
|
genre
|
|
mood
|
|
style
|
|
speed
|
|
theme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`, (t, data) => {
|
|
t.snapshot(data)
|
|
})
|
|
|
|
test('recordings have a theAudioDB field', testData, `
|
|
{
|
|
lookup {
|
|
recording(mbid: "1109d8da-ce4a-4739-9414-242dc3e9b81c") {
|
|
theAudioDB {
|
|
trackID
|
|
albumID
|
|
artistID
|
|
description
|
|
descriptionES: description(lang: "es")
|
|
thumbnail
|
|
thumbnailPreview: thumbnail(size: PREVIEW)
|
|
score
|
|
scoreVotes
|
|
trackNumber
|
|
musicVideo {
|
|
url
|
|
companyName
|
|
directorName
|
|
screenshots
|
|
screenshotsPreview: screenshots(size: PREVIEW)
|
|
viewCount
|
|
likeCount
|
|
dislikeCount
|
|
commentCount
|
|
}
|
|
genre
|
|
mood
|
|
style
|
|
theme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`, (t, data) => {
|
|
t.snapshot(data)
|
|
})
|