Add some test coverage in frontend/lib (#2615)
This commit is contained in:
@@ -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('')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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(
|
||||
''
|
||||
)
|
||||
given(
|
||||
'https://img.shields.io/badge.svg',
|
||||
'https://example.com/example',
|
||||
'Example'
|
||||
).expect(
|
||||
'[](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(
|
||||
|
||||
Reference in New Issue
Block a user