Add more schema tests

This commit is contained in:
Brian Beck 2016-12-07 06:16:30 -08:00
parent 33d45710fe
commit a72a0365d1
5 changed files with 107 additions and 0 deletions

Binary file not shown.

View 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"
}
}
}

Binary file not shown.

View 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"
}
}
}

View file

@ -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 ))
})
})