Add [dynamic-yaml] badge (#1623)
* Add dynamic yaml badge * Forgot package lock * Switch tests to yaml data source * Add yaml to the dynamic badge maker options * Reorder to match documentation examples * Reordered dynamic types to be alphabetical * Removed regex as pinend commit makes it unnecessary and fixed url * Removed unused import * Add more YAML MIME types * Removed duplicate tests which don't differ between data types
This commit is contained in:
committed by
Marcin Mielnicki
parent
47614e5bbc
commit
d56b6961da
@@ -43,6 +43,7 @@ export default class DynamicBadgeMaker extends React.Component {
|
||||
<option value="" disabled>data type</option>
|
||||
<option value="json">json</option>
|
||||
<option value="xml">xml</option>
|
||||
<option value="yaml">yaml</option>
|
||||
</select> {}
|
||||
<input
|
||||
className="short"
|
||||
|
||||
@@ -126,6 +126,9 @@ export default class Usage extends React.PureComponent {
|
||||
<p>
|
||||
<code>/badge/dynamic/xml.svg?url=<URL>&label=<LABEL>&query=<<a href="https://www.npmjs.com/package/xpath" target="_BLANK" title="XPath syntax">//data/subdata</a>>&colorB=<COLOR>&prefix=<PREFIX>&suffix=<SUFFIX></code>
|
||||
</p>
|
||||
<p>
|
||||
<code>/badge/dynamic/yaml.svg?url=<URL>&label=<LABEL>&query=<<a href="https://www.npmjs.com/package/jsonpath" target="_BLANK" title="JSONdata syntax">$.DATA.SUBDATA</a>>&colorB=<COLOR>&prefix=<PREFIX>&suffix=<SUFFIX></code>
|
||||
</p>
|
||||
|
||||
<hr className="spacing" />
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('Badge URL functions', function() {
|
||||
});
|
||||
|
||||
test(dynamicBadgeUrl, () => {
|
||||
const jsonUrl = 'http://example.com/foo.json';
|
||||
const dataUrl = 'http://example.com/foo.json';
|
||||
const query = '$.bar';
|
||||
const prefix = 'value: ';
|
||||
|
||||
@@ -46,35 +46,13 @@ describe('Badge URL functions', function() {
|
||||
'http://img.example.com',
|
||||
'json',
|
||||
'foo',
|
||||
jsonUrl,
|
||||
dataUrl,
|
||||
query,
|
||||
{ prefix, style: 'plastic' }
|
||||
).expect([
|
||||
'http://img.example.com/badge/dynamic/json.svg',
|
||||
'?label=foo',
|
||||
`&url=${encodeURIComponent(jsonUrl)}`,
|
||||
`&query=${encodeURIComponent(query)}`,
|
||||
`&prefix=${encodeURIComponent(prefix)}`,
|
||||
'&style=plastic',
|
||||
].join(''))
|
||||
});
|
||||
|
||||
test(dynamicBadgeUrl, () => {
|
||||
const xmlUrl = 'http://example.com/foo.xml';
|
||||
const query = '//bar';
|
||||
const prefix = 'value: ';
|
||||
|
||||
given(
|
||||
'http://img.example.com',
|
||||
'xml',
|
||||
'foo',
|
||||
xmlUrl,
|
||||
query,
|
||||
{ prefix, style: 'plastic' }
|
||||
).expect([
|
||||
'http://img.example.com/badge/dynamic/xml.svg',
|
||||
'?label=foo',
|
||||
`&url=${encodeURIComponent(xmlUrl)}`,
|
||||
`&url=${encodeURIComponent(dataUrl)}`,
|
||||
`&query=${encodeURIComponent(query)}`,
|
||||
`&prefix=${encodeURIComponent(prefix)}`,
|
||||
'&style=plastic',
|
||||
|
||||
Reference in New Issue
Block a user