mirror of
https://github.com/BradNut/graphbrainz
synced 2025-09-08 17:40:32 +00:00
Add more schema tests
This commit is contained in:
parent
33d45710fe
commit
a72a0365d1
5 changed files with 107 additions and 0 deletions
BIN
test/fixtures/05fcd912e8786fff4dca854a7fa44c81
vendored
Normal file
BIN
test/fixtures/05fcd912e8786fff4dca854a7fa44c81
vendored
Normal file
Binary file not shown.
29
test/fixtures/05fcd912e8786fff4dca854a7fa44c81.headers
vendored
Normal file
29
test/fixtures/05fcd912e8786fff4dca854a7fa44c81.headers
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"statusCode": 200,
|
||||
"headers": {
|
||||
"date": "Wed, 07 Dec 2016 14:11:09 GMT",
|
||||
"content-type": "application/json; charset=UTF-8",
|
||||
"transfer-encoding": "chunked",
|
||||
"connection": "keep-alive",
|
||||
"keep-alive": "timeout=15",
|
||||
"vary": "Accept-Encoding",
|
||||
"x-ratelimit-limit": "700",
|
||||
"x-ratelimit-remaining": "623",
|
||||
"x-ratelimit-reset": "1481119871",
|
||||
"last-modified": "Wed, 09 Nov 2016 23:43:24 GMT",
|
||||
"server": "Jetty(9.3.10.v20160621)",
|
||||
"access-control-allow-origin": "*",
|
||||
"content-encoding": "gzip"
|
||||
},
|
||||
"url": "http://musicbrainz.org:80/ws/2/recording?query=Burn%20the%20Witch&fmt=json",
|
||||
"time": 435,
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
|
||||
"host": "musicbrainz.org",
|
||||
"accept-encoding": "gzip, deflate",
|
||||
"accept": "application/json"
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
test/fixtures/e35ea8d15589d88c826a9dcf6e309f1d
vendored
Normal file
BIN
test/fixtures/e35ea8d15589d88c826a9dcf6e309f1d
vendored
Normal file
Binary file not shown.
29
test/fixtures/e35ea8d15589d88c826a9dcf6e309f1d.headers
vendored
Normal file
29
test/fixtures/e35ea8d15589d88c826a9dcf6e309f1d.headers
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"statusCode": 200,
|
||||
"headers": {
|
||||
"date": "Wed, 07 Dec 2016 14:15:04 GMT",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"transfer-encoding": "chunked",
|
||||
"connection": "keep-alive",
|
||||
"keep-alive": "timeout=15",
|
||||
"vary": "Accept-Encoding",
|
||||
"x-ratelimit-limit": "700",
|
||||
"x-ratelimit-remaining": "559",
|
||||
"x-ratelimit-reset": "1481120105",
|
||||
"server": "Plack::Handler::Starlet",
|
||||
"etag": "W/\"0f2ce1fbd4358ed2ee61c9e461538573\"",
|
||||
"access-control-allow-origin": "*",
|
||||
"content-encoding": "gzip"
|
||||
},
|
||||
"url": "http://musicbrainz.org:80/ws/2/release-group?artist=c8da2e40-bd28-4d4e-813a-bd2f51958ba8&fmt=json",
|
||||
"time": 390,
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"User-Agent": "graphbrainz/3.1.0 ( https://github.com/exogen/graphbrainz )",
|
||||
"host": "musicbrainz.org",
|
||||
"accept-encoding": "gzip, deflate",
|
||||
"accept": "application/json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,3 +40,52 @@ test('schema has a lookup query', t => {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('schema has a search query', t => {
|
||||
const query = `
|
||||
{
|
||||
search {
|
||||
recordings (query: "Burn the Witch") {
|
||||
totalCount
|
||||
edges {
|
||||
score
|
||||
node {
|
||||
mbid
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
return graphql(schema, query, null, t.context).then(result => {
|
||||
const { recordings } = result.data.search
|
||||
t.true(recordings.totalCount > 0)
|
||||
t.true(recordings.edges.length === 25)
|
||||
recordings.edges.forEach(edge => t.true(edge.score > 0))
|
||||
})
|
||||
})
|
||||
|
||||
test('schema has a browse query', t => {
|
||||
const query = `
|
||||
{
|
||||
browse {
|
||||
releaseGroups (artist: "c8da2e40-bd28-4d4e-813a-bd2f51958ba8") {
|
||||
totalCount
|
||||
edges {
|
||||
node {
|
||||
mbid
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
return graphql(schema, query, null, t.context).then(result => {
|
||||
const { releaseGroups } = result.data.browse
|
||||
t.true(releaseGroups.totalCount > 0)
|
||||
t.true(releaseGroups.edges.length > 0)
|
||||
releaseGroups.edges.forEach(edge => t.truthy(edge.node.title ))
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue