Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
2fd committed Dec 26, 2020
1 parent ab6650e commit e5e325f
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/utility/html.test.ts
@@ -1,4 +1,6 @@
import { Description, Field, InputValue, SchemaType } from '../interface'
import { split, HTML } from './html'
import { data } from '../../test/empty.schema.json'

test('utility/html.split', () => {
const LOREM_IPSU = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.`
Expand Down Expand Up @@ -69,4 +71,43 @@ describe('lib/utility/html#HTML', () => {
const html = new HTML
expect(html.comment('CODE')).toBe('<span class="comment line"># CODE</span>')
})

test('.identifier', () => {
const html = new HTML
const type = data.__schema.types.find(t => t.name === 'Query')
expect(html.identifier(type as Description)).toBe('<span class="identifier">Query</span>')
})

test('.parameter', () => {
const html = new HTML
const input: InputValue = data.__schema.types.find(t => t.name === 'AddCommentInput') as any
expect(html.parameter(input)).toBe('<span class="variable parameter">AddCommentInput</span>')
})

test('.property', () => {
const html = new HTML
expect(html.property('PROPERTY')).toBe('<span class="meta">PROPERTY</span>')
})

test('.useIdentifier', () => {
const html = new HTML
const schema: SchemaType = data.__schema.types.find(t => t.name === '__Schema') as any
const field: Field = (schema.fields || []).find(f => f.name === 'types') as any

expect(html.useIdentifier(field.type, 'HREF')).toBe('[<a class="support type" href="HREF">__Type</a>!]!')
})

test('.useIdentifierLength', () => {
const html = new HTML
const schema: SchemaType = data.__schema.types.find(t => t.name === '__Schema') as any
const field: Field = (schema.fields || []).find(f => f.name === 'types') as any

expect(html.useIdentifierLength(field.type)).toBe(10)
})

test('.value', () => {
const html = new HTML
expect(html.value('"STRING"')).toBe('<span class="string">"STRING"</span>')
expect(html.value('NUMBER')).toBe('<span class="constant numeric">NUMBER</span>')
})
})

0 comments on commit e5e325f

Please sign in to comment.