mirror of
https://github.com/BradNut/graphbrainz
synced 2025-09-08 17:40:32 +00:00
Add more scalar tests
This commit is contained in:
parent
003585fb86
commit
c2d2bfd246
1 changed files with 17 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import test from 'ava'
|
||||
import { Kind } from 'graphql/language'
|
||||
import { Locale, Duration, URLString } from '../../src/types/scalars'
|
||||
import { Duration, Locale, MBID, ISWC, URLString } from '../../src/types/scalars'
|
||||
|
||||
test('Locale scalar allows language code', t => {
|
||||
t.is(Locale.parseLiteral({ kind: Kind.STRING, value: 'en' }), 'en')
|
||||
|
|
@ -55,3 +55,19 @@ test('URLString scalar must be a valid URL', t => {
|
|||
t.throws(() => URLString.parseLiteral({ kind: Kind.STRING, value: 'foo://bar' }), TypeError)
|
||||
t.throws(() => URLString.parseLiteral({ kind: Kind.STRING, value: 'foo://bar.' }), TypeError)
|
||||
})
|
||||
|
||||
test('ISWC scalar only accepts strings', t => {
|
||||
t.is(ISWC.parseLiteral({ kind: Kind.STRING, value: 'foo' }), 'foo')
|
||||
t.is(ISWC.parseLiteral({ kind: Kind.INT, value: 5 }), null)
|
||||
t.is(ISWC.parseLiteral({ kind: Kind.ENUM, value: 'xx' }), null)
|
||||
})
|
||||
|
||||
test('MBID scalar only accepts strings', t => {
|
||||
t.is(MBID.parseLiteral({ kind: Kind.INT, value: 12345 }), null)
|
||||
t.is(MBID.parseLiteral({ kind: Kind.ENUM, value: 'xx' }), null)
|
||||
})
|
||||
|
||||
test('MBID scalar must be a valid UUID', t => {
|
||||
t.is(MBID.parseLiteral({ kind: Kind.STRING, value: 'c8da2e40-bd28-4d4e-813a-bd2f51958ba8' }), 'c8da2e40-bd28-4d4e-813a-bd2f51958ba8')
|
||||
t.throws(() => MBID.parseLiteral({ kind: Kind.STRING, value: 'c8da2e40-bd28-4d4e-813a-bd2f51958bag' }), TypeError)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue