Skip to content

Commit

Permalink
Add some test coverage in frontend/lib (#2615)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow authored Jan 2, 2019
1 parent 7150b37 commit a983984
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
18 changes: 18 additions & 0 deletions frontend/lib/badge-url.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,23 @@ describe('Badge URL functions', function() {
'&style=plastic',
].join('')
)

const suffix = '<- value'
const color = 'blue'
given('http://img.example.com', 'json', 'foo', dataUrl, query, {
suffix,
color,
style: 'plastic',
}).expect(
[
'http://img.example.com/badge/dynamic/json.svg',
'?label=foo',
`&url=${encodeURIComponent(dataUrl)}`,
`&query=${encodeURIComponent(query)}`,
'&colorB=blue',
`&suffix=${encodeURIComponent(suffix)}`,
'&style=plastic',
].join('')
)
})
})
50 changes: 49 additions & 1 deletion frontend/lib/generate-image-markup.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
import { test, given } from 'sazerac'
import generateAllMarkup from './generate-image-markup'
import generateAllMarkup, {
markdown,
reStructuredText,
asciiDoc,
} from './generate-image-markup'

test(markdown, () => {
given('https://img.shields.io/badge.svg', undefined, 'Example').expect(
'![Example](https://img.shields.io/badge.svg)'
)
given(
'https://img.shields.io/badge.svg',
'https://example.com/example',
'Example'
).expect(
'[![Example](https://img.shields.io/badge.svg)](https://example.com/example)'
)
})

test(reStructuredText, () => {
given('https://img.shields.io/badge.svg', undefined, 'Example').expect(
'.. image:: https://img.shields.io/badge.svg :alt: Example'
)
given(
'https://img.shields.io/badge.svg',
'https://example.com/example',
'Example'
).expect(
'.. image:: https://img.shields.io/badge.svg :alt: Example :target: https://example.com/example'
)
})

test(asciiDoc, () => {
given('https://img.shields.io/badge.svg', undefined, 'Example').expect(
'image:https://img.shields.io/badge.svg[Example]'
)
given(
'https://img.shields.io/badge.svg',
undefined,
'Example, with comma'
).expect('image:https://img.shields.io/badge.svg["Example, with comma"]')
given(
'https://img.shields.io/badge.svg',
'https://example.com/example',
'Example'
).expect(
'image:https://img.shields.io/badge.svg["Example",link="https://example.com/example"]'
)
})

test(generateAllMarkup, () => {
given(
Expand Down

0 comments on commit a983984

Please sign in to comment.