2018-06-22 16:35:24 +00:00
|
|
|
const tap = require('tap')
|
|
|
|
const badgen = require('..')
|
2018-08-31 05:34:36 +00:00
|
|
|
const icons = require('./icon-data-uri.js')
|
2018-06-22 16:35:24 +00:00
|
|
|
|
|
|
|
tap.test('generate badge with { subject, status }', t => {
|
|
|
|
const svg = badgen({ subject: 'npm', status: 'v1.0.0' })
|
2018-07-01 08:19:07 +00:00
|
|
|
t.ok(typeof svg === 'string', 'successfully generated')
|
2018-07-19 05:46:08 +00:00
|
|
|
t.matchSnapshot(svg, 'snapshot')
|
2018-06-22 16:35:24 +00:00
|
|
|
t.end()
|
|
|
|
})
|
|
|
|
|
|
|
|
tap.test('generate badge with { subject, status, color }', t => {
|
|
|
|
const svg = badgen({ subject: 'npm', status: 'v1.0.0', color: 'ADF' })
|
2018-07-01 08:19:07 +00:00
|
|
|
t.ok(typeof svg === 'string', 'successfully generated')
|
2018-07-19 05:46:08 +00:00
|
|
|
t.matchSnapshot(svg, 'snapshot')
|
2018-06-22 16:35:24 +00:00
|
|
|
t.end()
|
|
|
|
})
|
2018-07-15 09:25:25 +00:00
|
|
|
|
2018-07-16 13:58:23 +00:00
|
|
|
tap.test('generate badge with { subject, status, style }', t => {
|
|
|
|
const svg = badgen({ subject: 'npm', status: 'v1.0.0', style: 'flat' })
|
2018-07-15 09:25:25 +00:00
|
|
|
t.ok(typeof svg === 'string', 'successfully generated')
|
2018-07-19 05:46:08 +00:00
|
|
|
t.matchSnapshot(svg, 'snapshot')
|
2018-07-15 09:25:25 +00:00
|
|
|
t.end()
|
|
|
|
})
|
|
|
|
|
2018-07-16 13:58:23 +00:00
|
|
|
tap.test('generate badge with { subject, status, color, style }', t => {
|
|
|
|
const svg = badgen({ subject: 'npm', status: 'v1.0.0', color: 'ADF', style: 'flat' })
|
2018-07-15 09:25:25 +00:00
|
|
|
t.ok(typeof svg === 'string', 'successfully generated')
|
2018-07-19 05:46:08 +00:00
|
|
|
t.matchSnapshot(svg, 'snapshot')
|
2018-07-15 09:25:25 +00:00
|
|
|
t.end()
|
|
|
|
})
|
2018-07-20 03:15:46 +00:00
|
|
|
|
|
|
|
tap.test('generate badge with { subject, status, icon }', t => {
|
2018-08-31 05:34:36 +00:00
|
|
|
const svg = badgen({ subject: 'docker', status: 'icon', icon: icons.chrome })
|
2018-07-20 03:15:46 +00:00
|
|
|
t.matchSnapshot(svg, 'snapshot')
|
|
|
|
t.end()
|
|
|
|
})
|
|
|
|
|
2018-08-06 07:25:01 +00:00
|
|
|
tap.test('generate badge with { status, icon }', t => {
|
2018-08-31 05:34:36 +00:00
|
|
|
const svg = badgen({ subject: '', status: 'icon', icon: icons.chrome })
|
2018-08-06 07:25:01 +00:00
|
|
|
t.matchSnapshot(svg, 'snapshot')
|
|
|
|
t.end()
|
|
|
|
})
|
|
|
|
|
2018-08-24 05:26:08 +00:00
|
|
|
tap.test('generate badge with { status, icon, iconWidth }', t => {
|
2018-08-31 05:34:36 +00:00
|
|
|
const svg = badgen({ subject: '', status: 'icon', icon: icons.lgtm, iconWidth: 19 })
|
2018-08-24 05:26:08 +00:00
|
|
|
t.matchSnapshot(svg, 'snapshot')
|
|
|
|
t.end()
|
|
|
|
})
|
|
|
|
|
2018-07-20 03:15:46 +00:00
|
|
|
tap.test('generate badge with { subject, status, icon, style }', t => {
|
2018-08-31 05:34:36 +00:00
|
|
|
const svg = badgen({ subject: 'docker', status: 'icon', style: 'flat', icon: icons.lgtm })
|
2018-07-20 03:15:46 +00:00
|
|
|
t.matchSnapshot(svg, 'snapshot')
|
|
|
|
t.end()
|
|
|
|
})
|
2018-07-25 03:30:00 +00:00
|
|
|
|
|
|
|
tap.test('type checking', t => {
|
|
|
|
t.throws(() => badgen({ status: '' }), TypeError, 'throw if subject is non-string')
|
|
|
|
t.throws(() => badgen({ subject: '' }), TypeError, 'throw if status is non-string')
|
|
|
|
t.end()
|
|
|
|
})
|