kopia lustrzana https://github.com/badgen/badgen
Porównaj commity
45 Commity
Autor | SHA1 | Data |
---|---|---|
Amio | a303e46dad | |
Amio Jin | 23108a625f | |
dependabot[bot] | 25ee3bd4bd | |
简静凡 | 665dc507ee | |
Amio | fdfe99c051 | |
Amio | 2ca1ce4755 | |
Amio | 609f95c21a | |
Amio | 18f79c98b8 | |
Amio | 49b999f5da | |
Amio | ef2f2914d8 | |
Andrew Patton | ab4c32e145 | |
chris48s | df6c6f026d | |
amio | f9cede8f8d | |
amio | c22fc7c16b | |
Frantisek Vymazal | 2046b6f993 | |
dependabot[bot] | 484f212b8d | |
Samim Mirhosseini | dae2b390de | |
amio | f9729c0ab1 | |
Evelyn Hathaway | c150c95057 | |
Amio | e8da026791 | |
Amio | d1cbed3588 | |
Evelyn Hathaway | 179a1d3c2a | |
amio | 49f8e3d9b4 | |
amio | 9b9b2ab423 | |
amio | 95ff63dbae | |
amio | 4917cf9263 | |
dependabot[bot] | 45213df5a2 | |
amio | d1db1d6d72 | |
amio | c50fa5b922 | |
amio | df0e3a55ae | |
amio | 79e7b0fff9 | |
amio | 4e7677ef37 | |
amio | 77f514849f | |
amio | 5b8bb922da | |
amio | 997fcb6740 | |
amio | 2d37d4f0c2 | |
amio | c81a539a2b | |
amio | a8fcb2f5f4 | |
amio | 0a2dd9d00e | |
amio | 3ef0141295 | |
amio | 9543aa138d | |
amio | 34c0d1e3f3 | |
amio | 1d398838b4 | |
amio | 0ea0ae366c | |
amio | db29bba8d7 |
|
@ -0,0 +1,26 @@
|
|||
name: Node CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node: [12, 14, 16, 18]
|
||||
os: [ubuntu-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: use Node.js ${{ matrix.node }} on ${{ matrix.os }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- name: Run npm ci
|
||||
run: npm ci
|
||||
- name: Run npm build
|
||||
run: npm run build --ifpresent
|
||||
- name: Run npm test
|
||||
run: npm test
|
45
README.md
45
README.md
|
@ -2,31 +2,32 @@
|
|||
|
||||
[![npm version][npm-src]][npm-href]
|
||||
[![Coverage Status][coveralls-src]][coveralls-href]
|
||||
[![Install size][packagephobia-src]][packagephobia-href]
|
||||
[![Bundle size][bundlephobia-src]][bundlephobia-href]
|
||||
[![License][license-src]][license-href]
|
||||
|
||||
Fast handcraft svg badge generator. Used on [badgen.net](https://badgen.net).
|
||||
|
||||
- 🌀 Zero dependency
|
||||
- ⚡️ Fast by design (see [benchmarks](#benchmarks))
|
||||
- 👯 Pure JavaScript, running in node & browser
|
||||
- 👯 Running in node & browser
|
||||
|
||||
## Usage
|
||||
|
||||
`npm install badgen`
|
||||
|
||||
```javascript
|
||||
const badgen = require('badgen')
|
||||
const { badgen } = require('badgen')
|
||||
|
||||
// only `status` is required.
|
||||
const svgString = badgen({
|
||||
label: 'npm', // <Text>
|
||||
labelColor: 'ADF' // <Color RGB> or <Color Name> (default 555)
|
||||
status: 'v1.2.3', // <Text>, required
|
||||
color: 'blue', // <Color RGB> or <Color Name> (default blue)
|
||||
style: 'flat', // 'flat' or undefined
|
||||
icon: 'data:image/svg+xml;base64,...', // Use icon
|
||||
iconWidth: 13, // Set this if icon is not square
|
||||
label: 'npm', // <Text>
|
||||
labelColor: 'ADF', // <Color RGB> or <Color Name> (default: '555')
|
||||
status: 'v1.2.3', // <Text>, required
|
||||
color: 'blue', // <Color RGB> or <Color Name> (default: 'blue')
|
||||
style: 'flat', // 'flat' or 'classic' (default: 'classic')
|
||||
icon: 'data:image/svg+xml;base64,...', // Use icon (default: undefined)
|
||||
iconWidth: 13, // Set this if icon is not square (default: 13)
|
||||
scale: 1 // Set badge scale (default: 1)
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -46,7 +47,7 @@ Available color names:
|
|||
### In browser
|
||||
|
||||
```html
|
||||
<script src="https://wzrd.in/standalone/badgen@latest"></script>
|
||||
<script src="https://unpkg.com/badgen"></script>
|
||||
<script>
|
||||
var svgString = badgen({ /*...*/ })
|
||||
</script>
|
||||
|
@ -54,17 +55,17 @@ Available color names:
|
|||
|
||||
## Benchmarks
|
||||
|
||||
`npm run bench` on my MacBook Pro (Early 2015), 2.7G i5, with Node.js 10.9.0:
|
||||
`npm run bench` on iMac 5K (Late 2014), 3.5G i5, with Node.js 12.11.0:
|
||||
|
||||
```bash
|
||||
[classic] style, long params x 784,111 ops/sec ±1.53% (89 runs sampled)
|
||||
[classic] style, full params x 1,096,667 ops/sec ±1.37% (90 runs sampled)
|
||||
[classic] style, with emoji x 1,086,230 ops/sec ±1.85% (92 runs sampled)
|
||||
[classic] style, with icon x 941,914 ops/sec ±0.41% (93 runs sampled)
|
||||
[flat] style, long params x 546,447 ops/sec ±0.52% (91 runs sampled)
|
||||
[flat] style, full params x 612,977 ops/sec ±1.08% (94 runs sampled)
|
||||
[flat] style, with emoji x 620,193 ops/sec ±0.95% (92 runs sampled)
|
||||
[flat] style, with icon x 566,848 ops/sec ±0.84% (93 runs sampled)
|
||||
[classic] style, long params x 985,898 ops/sec ±0.37% (94 runs sampled)
|
||||
[classic] style, full params x 1,284,886 ops/sec ±0.42% (95 runs sampled)
|
||||
[classic] style, with emoji x 1,291,768 ops/sec ±0.28% (95 runs sampled)
|
||||
[classic] style, with icon x 1,177,120 ops/sec ±0.94% (95 runs sampled)
|
||||
[flat] style, long params x 780,504 ops/sec ±0.39% (94 runs sampled)
|
||||
[flat] style, full params x 1,012,111 ops/sec ±0.40% (97 runs sampled)
|
||||
[flat] style, with emoji x 1,013,695 ops/sec ±0.91% (95 runs sampled)
|
||||
[flat] style, with icon x 994,481 ops/sec ±0.30% (94 runs sampled)
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
@ -73,8 +74,8 @@ Available color names:
|
|||
|
||||
[npm-src]: https://badgen.net/npm/v/badgen
|
||||
[npm-href]: https://www.npmjs.com/package/badgen
|
||||
[packagephobia-src]: https://badgen.net/packagephobia/install/badgen
|
||||
[packagephobia-href]: https://packagephobia.now.sh/result?p=badgen
|
||||
[bundlephobia-src]: https://badgen.net/bundlephobia/minzip/badgen
|
||||
[bundlephobia-href]: https://bundlephobia.com/result?p=badgen
|
||||
[coveralls-src]: https://badgen.net/coveralls/c/github/amio/badgen/master
|
||||
[coveralls-href]: https://coveralls.io/github/amio/badgen?branch=master
|
||||
[license-src]: https://badgen.net/github/license/amio/badgen
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { Suite } = require('benchmark')
|
||||
const badgen = require('..')
|
||||
const icon = require('../test/icon-data-uri.js')
|
||||
const { badgen } = require('..')
|
||||
const icon = require('../test/assets/icon-data-uri.js')
|
||||
|
||||
/* eslint max-len: ["error", { "code": 90 }] */
|
||||
const longParams = { subject: 'build-build-build', status: 'passing-passing-passing' }
|
||||
|
|
Plik diff jest za duży
Load Diff
27
package.json
27
package.json
|
@ -1,27 +1,34 @@
|
|||
{
|
||||
"name": "badgen",
|
||||
"version": "2.8.2",
|
||||
"version": "3.2.3",
|
||||
"description": "Fast svg badge generator.",
|
||||
"repository": "amio/badgen",
|
||||
"author": "Amio <amio.cn@gmail.com>",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"unpkg": "dist/index.browser.js",
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"bench": "node bench/index.js",
|
||||
"preview": "node preview/serve.js",
|
||||
"snaptests": "TAP_SNAPSHOT=1 npm test",
|
||||
"pretest": "npm run lint && npm run build",
|
||||
"test": "tap test/*.spec.js --reporter spec --coverage",
|
||||
"build": "ncc -s -m --no-source-map-register build src/index.js && cp src/*.d.ts dist",
|
||||
"prepublishOnly": "npm run build"
|
||||
"pretest": "npm run build",
|
||||
"test": "tap --no-check-coverage",
|
||||
"prebuild": "rm -rf dist",
|
||||
"esbuild": "esbuild src/index.ts --bundle --minify --sourcemap",
|
||||
"build:types": "tsc --emitDeclarationOnly",
|
||||
"build:browser": "npm run esbuild -- --outfile=dist/index.browser.js",
|
||||
"build:node": "npm run esbuild -- --platform=node --outfile=dist/index.js",
|
||||
"build": "npm run build:browser && npm run build:node",
|
||||
"postbuild": "npm run build:types",
|
||||
"prepack": "npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@zeit/ncc": "^0.20.4",
|
||||
"@types/node": "^14.0.14",
|
||||
"benchmark": "^2.1.4",
|
||||
"serve-marked": "^2.0.0",
|
||||
"standard": "^12.0.0",
|
||||
"tap": "^14.4.1"
|
||||
"esbuild": "^0.14.38",
|
||||
"serve-marked": "^3.1.0",
|
||||
"tap": "^16.1.0",
|
||||
"typescript": "^4.1.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,4 +60,4 @@
|
|||
|
||||
## Edge Cases
|
||||
|
||||
![](/<{[(&)]}>/<{[(&)]}>)
|
||||
![](/'"<{[(&)]}>"'/'"<{[(&)]}>"')
|
||||
|
|
|
@ -3,20 +3,20 @@ const path = require('path')
|
|||
const http = require('http')
|
||||
const url = require('url')
|
||||
const qs = require('querystring')
|
||||
const serveMarked = require('serve-marked')
|
||||
const badgen = require('..')
|
||||
const serveMarked = require('serve-marked').default
|
||||
const { badgen } = require('..')
|
||||
|
||||
const icons = require('../test/assets/icon-data-uri.js')
|
||||
|
||||
const serveBadge = (req, res) => {
|
||||
const { pathname, query } = url.parse(req.url)
|
||||
const { label, style, icon, iconWidth, labelColor } = qs.parse(query)
|
||||
const [ subject, status, color ] = pathname.split('/').splice(1)
|
||||
const { icon, ...queryParams } = qs.parse(query)
|
||||
const [subject, status, color] = pathname.split('/').splice(1)
|
||||
.map(s => qs.unescape(s))
|
||||
|
||||
res.statusCode = 200
|
||||
res.setHeader('Content-Type', 'image/svg+xml;charset=utf-8')
|
||||
res.end(badgen({ label, labelColor, subject, status, color, style, icon: icons[icon], iconWidth }))
|
||||
res.end(badgen({ subject, status, color, icon: icons[icon], ...queryParams }))
|
||||
}
|
||||
|
||||
const md = fs.readFileSync(path.join(__dirname, 'preview.md'), 'utf8')
|
||||
|
@ -47,7 +47,10 @@ http.createServer((req, res) => {
|
|||
case '/favicon.ico':
|
||||
return serve404(req, res)
|
||||
default:
|
||||
return serveBadge(req, res)
|
||||
if (req.url.split('/').length > 2)
|
||||
return serveBadge(req, res)
|
||||
else
|
||||
return serve404(req, res)
|
||||
}
|
||||
}).listen(port)
|
||||
|
||||
|
|
41
src/bare.js
41
src/bare.js
|
@ -1,41 +0,0 @@
|
|||
const calcWidth = require('./calc-text-width.js').Verdana110
|
||||
const colorPresets = require('./color-presets.js')
|
||||
const { sanitize, typeAssert } = require('./utils.js')
|
||||
|
||||
module.exports = ({ status, color, style }) => {
|
||||
typeAssert(typeof status === 'string', '<status> must be string')
|
||||
color = colorPresets[color] || color || colorPresets['blue']
|
||||
|
||||
const stTextWidth = calcWidth(status)
|
||||
const stRectWidth = stTextWidth + 115
|
||||
|
||||
status = sanitize(status)
|
||||
|
||||
if (style === 'flat') {
|
||||
return `<svg width="${stRectWidth / 10}" height="20" viewBox="0 0 ${stRectWidth} 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect fill="#${color}" x="0" width="${stRectWidth}" height="200"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="${stTextWidth}" fill="#000" opacity="0.1">${status}</text>
|
||||
<text x="55" y="138" textLength="${stTextWidth}">${status}</text>
|
||||
</g>
|
||||
</svg>`
|
||||
}
|
||||
|
||||
return `<svg width="${stRectWidth / 10}" height="20" viewBox="0 0 ${stRectWidth} 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="${stRectWidth}" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="${stRectWidth}" height="200" fill="#${color}" x="0"/>
|
||||
<rect width="${stRectWidth}" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="${stTextWidth}" fill="#000" opacity="0.25">${status}</text>
|
||||
<text x="55" y="138" textLength="${stTextWidth}">${status}</text>
|
||||
</g>
|
||||
</svg>`
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
const widthsVerdana110 = require('./widths-verdana-110.json')
|
||||
// import widthsVerdana110 from './widths-verdana-110.json'
|
||||
// @ts-ignore
|
||||
const widthsVerdana110: number[] = require('./widths-verdana-110.json')
|
||||
|
||||
const calcWidth = (charWidthTable) => {
|
||||
const calcWidth = (charWidthTable: number[]) => {
|
||||
const fallbackWidth = charWidthTable[64] // Width as "@" for overflows
|
||||
|
||||
return ([...text]) => {
|
||||
|
@ -15,6 +17,4 @@ const calcWidth = (charWidthTable) => {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Verdana110: calcWidth(widthsVerdana110)
|
||||
}
|
||||
export const Verdana110 = calcWidth(widthsVerdana110)
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = {
|
||||
export default {
|
||||
green: '3C1',
|
||||
blue: '08C',
|
||||
red: 'E43',
|
||||
|
@ -10,4 +10,4 @@ module.exports = {
|
|||
gray: '999',
|
||||
cyan: '1BC',
|
||||
black: '2A2A2A'
|
||||
}
|
||||
} as Record<string, string>
|
|
@ -1,14 +0,0 @@
|
|||
interface BadgenOptions {
|
||||
status: string;
|
||||
subject?: string;
|
||||
color?: string;
|
||||
label?: string;
|
||||
labelColor?: string
|
||||
style?: StyleOption;
|
||||
icon?: string;
|
||||
iconWidth?: 13;
|
||||
}
|
||||
|
||||
type StyleOption = 'flat' | 'classic'
|
||||
|
||||
export default function badgen(options: BadgenOptions): string;
|
77
src/index.js
77
src/index.js
|
@ -1,77 +0,0 @@
|
|||
const calcWidth = require('./calc-text-width.js').Verdana110
|
||||
const colorPresets = require('./color-presets.js')
|
||||
const { sanitize, typeAssert } = require('./utils.js')
|
||||
|
||||
const bare = require('./bare.js')
|
||||
|
||||
module.exports = ({
|
||||
label,
|
||||
subject,
|
||||
status,
|
||||
color = 'blue',
|
||||
style,
|
||||
icon,
|
||||
iconWidth = 13,
|
||||
labelColor = '555'
|
||||
}) => {
|
||||
typeAssert(typeof status === 'string', '<status> must be string')
|
||||
|
||||
label = label === undefined ? subject : label // subject is deprecated
|
||||
if (!label && !icon) {
|
||||
return bare({ status, color, style })
|
||||
}
|
||||
|
||||
color = colorPresets[color] || color
|
||||
labelColor = colorPresets[labelColor] || labelColor
|
||||
iconWidth = iconWidth * 10
|
||||
|
||||
const iconSpanWidth = icon ? (label.length ? iconWidth + 30 : iconWidth - 18) : 0
|
||||
const sbTextStart = icon ? (iconSpanWidth + 50) : 50
|
||||
const sbTextWidth = calcWidth(label)
|
||||
const stTextWidth = calcWidth(status)
|
||||
const sbRectWidth = sbTextWidth + 100 + iconSpanWidth
|
||||
const stRectWidth = stTextWidth + 100
|
||||
const width = sbRectWidth + stRectWidth
|
||||
const xlink = icon ? ' xmlns:xlink="http://www.w3.org/1999/xlink"' : ''
|
||||
|
||||
label = sanitize(label)
|
||||
status = sanitize(status)
|
||||
|
||||
if (style === 'flat') {
|
||||
return `<svg width="${width / 10}" height="20" viewBox="0 0 ${width} 200" xmlns="http://www.w3.org/2000/svg"${xlink}>
|
||||
<g>
|
||||
<rect fill="#${labelColor}" width="${sbRectWidth}" height="200"/>
|
||||
<rect fill="#${color}" x="${sbRectWidth}" width="${stRectWidth}" height="200"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="${sbTextStart + 10}" y="148" textLength="${sbTextWidth}" fill="#000" opacity="0.1">${label}</text>
|
||||
<text x="${sbTextStart}" y="138" textLength="${sbTextWidth}">${label}</text>
|
||||
<text x="${sbRectWidth + 55}" y="148" textLength="${stTextWidth}" fill="#000" opacity="0.1">${status}</text>
|
||||
<text x="${sbRectWidth + 45}" y="138" textLength="${stTextWidth}">${status}</text>
|
||||
</g>
|
||||
${icon ? `<image x="40" y="35" width="${iconWidth}" height="132" xlink:href="${icon}"/>` : ''}
|
||||
</svg>`
|
||||
}
|
||||
|
||||
return `<svg width="${width / 10}" height="20" viewBox="0 0 ${width} 200" xmlns="http://www.w3.org/2000/svg"${xlink}>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="${width}" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="${sbRectWidth}" height="200" fill="#${labelColor}"/>
|
||||
<rect width="${stRectWidth}" height="200" fill="#${color}" x="${sbRectWidth}"/>
|
||||
<rect width="${width}" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="${sbTextStart + 10}" y="148" textLength="${sbTextWidth}" fill="#000" opacity="0.25">${label}</text>
|
||||
<text x="${sbTextStart}" y="138" textLength="${sbTextWidth}">${label}</text>
|
||||
<text x="${sbRectWidth + 55}" y="148" textLength="${stTextWidth}" fill="#000" opacity="0.25">${status}</text>
|
||||
<text x="${sbRectWidth + 45}" y="138" textLength="${stTextWidth}">${status}</text>
|
||||
</g>
|
||||
${icon ? `<image x="40" y="35" width="${iconWidth}" height="130" xlink:href="${icon}"/>` : ''}
|
||||
</svg>`
|
||||
}
|
||||
|
||||
module.exports.default = module.exports
|
|
@ -0,0 +1,186 @@
|
|||
export { Verdana110 as calcWidth } from './calc-text-width'
|
||||
import { Verdana110 as calcWidth } from './calc-text-width'
|
||||
import colorPresets from './color-presets'
|
||||
|
||||
export type StyleOption = 'flat' | 'classic'
|
||||
export type ColorPreset = keyof typeof colorPresets
|
||||
|
||||
export interface BadgenOptions {
|
||||
status: string;
|
||||
subject?: string;
|
||||
color?: ColorPreset;
|
||||
label?: string;
|
||||
labelColor?: string
|
||||
style?: StyleOption;
|
||||
icon?: string;
|
||||
iconWidth?: number;
|
||||
scale?: number
|
||||
}
|
||||
|
||||
export function badgen ({
|
||||
label,
|
||||
subject,
|
||||
status,
|
||||
color = 'blue',
|
||||
style,
|
||||
icon,
|
||||
iconWidth = 13,
|
||||
labelColor = '555',
|
||||
scale = 1
|
||||
}: BadgenOptions) {
|
||||
typeAssert(typeof status === 'string', '<status> must be string')
|
||||
|
||||
label = label === undefined ? subject : label // subject is deprecated
|
||||
if (!label && !icon) {
|
||||
return bare({ status, color, style, scale })
|
||||
}
|
||||
|
||||
color = colorPresets[color] || color
|
||||
labelColor = colorPresets[labelColor] || labelColor
|
||||
iconWidth = iconWidth * 10
|
||||
|
||||
const iconSpanWidth = icon ? (label?.length ? iconWidth + 30 : iconWidth - 18) : 0
|
||||
const sbTextStart = icon ? (iconSpanWidth + 50) : 50
|
||||
const sbTextWidth = label ? calcWidth(label) : 0
|
||||
const stTextWidth = calcWidth(status)
|
||||
const sbRectWidth = sbTextWidth + 100 + iconSpanWidth
|
||||
const stRectWidth = stTextWidth + 100
|
||||
const width = sbRectWidth + stRectWidth
|
||||
const xlink = icon ? ' xmlns:xlink="http://www.w3.org/1999/xlink"' : ''
|
||||
|
||||
const gradientId = generateRandomID(5)
|
||||
const maskId = generateRandomID(5)
|
||||
|
||||
label = label ? sanitize(label) : ''
|
||||
status = sanitize(status)
|
||||
color = sanitize(color)
|
||||
labelColor = sanitize(labelColor)
|
||||
icon = icon ? sanitize(icon) : icon
|
||||
const accessibleText = createAccessibleText({label, status})
|
||||
|
||||
if (style === 'flat') {
|
||||
return `<svg width="${scale * width / 10}" height="${scale * 20}" viewBox="0 0 ${width} 200" xmlns="http://www.w3.org/2000/svg"${xlink} role="img" aria-label="${accessibleText}">
|
||||
<title>${accessibleText}</title>
|
||||
<g>
|
||||
<rect fill="#${labelColor}" width="${sbRectWidth}" height="200"/>
|
||||
<rect fill="#${color}" x="${sbRectWidth}" width="${stRectWidth}" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="${sbTextStart + 10}" y="148" textLength="${sbTextWidth}" fill="#000" opacity="0.1">${label}</text>
|
||||
<text x="${sbTextStart}" y="138" textLength="${sbTextWidth}">${label}</text>
|
||||
<text x="${sbRectWidth + 55}" y="148" textLength="${stTextWidth}" fill="#000" opacity="0.1">${status}</text>
|
||||
<text x="${sbRectWidth + 45}" y="138" textLength="${stTextWidth}">${status}</text>
|
||||
</g>
|
||||
${icon ? `<image x="40" y="35" width="${iconWidth}" height="132" xlink:href="${icon}"/>` : ''}
|
||||
</svg>`
|
||||
}
|
||||
|
||||
return `<svg width="${scale * width / 10}" height="${scale * 20}" viewBox="0 0 ${width} 200" xmlns="http://www.w3.org/2000/svg"${xlink} role="img" aria-label="${accessibleText}">
|
||||
<title>${accessibleText}</title>
|
||||
<linearGradient id="${gradientId}" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="${maskId}"><rect width="${width}" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#${maskId})">
|
||||
<rect width="${sbRectWidth}" height="200" fill="#${labelColor}"/>
|
||||
<rect width="${stRectWidth}" height="200" fill="#${color}" x="${sbRectWidth}"/>
|
||||
<rect width="${width}" height="200" fill="url(#${gradientId})"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="${sbTextStart + 10}" y="148" textLength="${sbTextWidth}" fill="#000" opacity="0.25">${label}</text>
|
||||
<text x="${sbTextStart}" y="138" textLength="${sbTextWidth}">${label}</text>
|
||||
<text x="${sbRectWidth + 55}" y="148" textLength="${stTextWidth}" fill="#000" opacity="0.25">${status}</text>
|
||||
<text x="${sbRectWidth + 45}" y="138" textLength="${stTextWidth}">${status}</text>
|
||||
</g>
|
||||
${icon ? `<image x="40" y="35" width="${iconWidth}" height="130" xlink:href="${icon}"/>` : ''}
|
||||
</svg>`
|
||||
}
|
||||
|
||||
function bare ({ status, color = 'blue', style, scale = 1 }: BadgenOptions) {
|
||||
typeAssert(typeof status === 'string', '<status> must be string')
|
||||
color = colorPresets[color] || color || colorPresets.blue
|
||||
|
||||
const stTextWidth = calcWidth(status)
|
||||
const stRectWidth = stTextWidth + 115
|
||||
|
||||
const gradientId = generateRandomID(5)
|
||||
const maskId = generateRandomID(5)
|
||||
|
||||
status = sanitize(status)
|
||||
color = sanitize(color)
|
||||
|
||||
if (style === 'flat') {
|
||||
return `<svg width="${scale * stRectWidth / 10}" height="${scale * 20}" viewBox="0 0 ${stRectWidth} 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="${status}">
|
||||
<title>${status}</title>
|
||||
<g>
|
||||
<rect fill="#${color}" x="0" width="${stRectWidth}" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="${stTextWidth}" fill="#000" opacity="0.1">${status}</text>
|
||||
<text x="55" y="138" textLength="${stTextWidth}">${status}</text>
|
||||
</g>
|
||||
</svg>`
|
||||
}
|
||||
|
||||
return `<svg width="${scale * stRectWidth / 10}" height="${scale * 20}" viewBox="0 0 ${stRectWidth} 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="${status}">
|
||||
<title>${status}</title>
|
||||
<linearGradient id="${gradientId}" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="${maskId}"><rect width="${stRectWidth}" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#${maskId})">
|
||||
<rect width="${stRectWidth}" height="200" fill="#${color}" x="0"/>
|
||||
<rect width="${stRectWidth}" height="200" fill="url(#${gradientId})"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="${stTextWidth}" fill="#000" opacity="0.25">${status}</text>
|
||||
<text x="55" y="138" textLength="${stTextWidth}">${status}</text>
|
||||
</g>
|
||||
</svg>`
|
||||
}
|
||||
|
||||
function sanitize (str: string): string {
|
||||
return str
|
||||
.replace(/\u0026/g, '&')
|
||||
.replace(/\u003C/g, '<')
|
||||
.replace(/\u003E/g, '>')
|
||||
.replace(/\u0022/g, '"')
|
||||
.replace(/\u0027/g, ''')
|
||||
}
|
||||
|
||||
interface AccessibleTextProps {
|
||||
status: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
function generateRandomID(length: number): string {
|
||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
let result = '';
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createAccessibleText({label, status}: AccessibleTextProps): string {
|
||||
const labelPrefix = label ? `${label}: ` : '';
|
||||
return labelPrefix + status;
|
||||
}
|
||||
|
||||
function typeAssert (assertion: boolean, message: string): void {
|
||||
if (!assertion) throw new TypeError(message)
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
badgen: typeof badgen;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window === 'object') {
|
||||
window.badgen = badgen
|
||||
}
|
11
src/utils.js
11
src/utils.js
|
@ -1,11 +0,0 @@
|
|||
|
||||
const sanitize = str => str.replace(/\u0026/g, '&').replace(/\u003C/g, '<')
|
||||
|
||||
const typeAssert = (assertion, message) => {
|
||||
if (!assertion) throw new TypeError(message)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
sanitize,
|
||||
typeAssert
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* Make sure to inspect the output below. Do not ignore changes!
|
||||
*/
|
||||
'use strict'
|
||||
exports[`test/index.spec.js TAP generate badge with { label, status } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
|
@ -27,7 +27,7 @@ exports[`test/index.spec.js TAP generate badge with { label, status } > snapshot
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate badge with { label, status, color } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, color } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
|
@ -49,7 +49,7 @@ exports[`test/index.spec.js TAP generate badge with { label, status, color } > s
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate badge with { label, status, color, style } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, color, style } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect fill="#555" width="349" height="200"/>
|
||||
|
@ -65,7 +65,7 @@ exports[`test/index.spec.js TAP generate badge with { label, status, color, styl
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate badge with { label, status, icon } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, icon } > snapshot 1`] = `
|
||||
<svg width="95.5" height="20" viewBox="0 0 955 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
|
@ -87,7 +87,7 @@ exports[`test/index.spec.js TAP generate badge with { label, status, icon } > sn
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate badge with { label, status, icon, style } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, icon, style } > snapshot 1`] = `
|
||||
<svg width="95.5" height="20" viewBox="0 0 955 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g>
|
||||
<rect fill="#555" width="631" height="200"/>
|
||||
|
@ -103,7 +103,7 @@ exports[`test/index.spec.js TAP generate badge with { label, status, icon, style
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate badge with { label, status, style } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, style } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect fill="#555" width="349" height="200"/>
|
||||
|
@ -119,7 +119,7 @@ exports[`test/index.spec.js TAP generate badge with { label, status, style } > s
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate badge with { status, icon } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate badge with { status, icon } > snapshot 1`] = `
|
||||
<svg width="53.6" height="20" viewBox="0 0 536 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
|
@ -141,7 +141,7 @@ exports[`test/index.spec.js TAP generate badge with { status, icon } > snapshot
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate badge with { status, icon, iconWidth } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate badge with { status, icon, iconWidth } > snapshot 1`] = `
|
||||
<svg width="59.6" height="20" viewBox="0 0 596 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
|
@ -163,7 +163,7 @@ exports[`test/index.spec.js TAP generate badge with { status, icon, iconWidth }
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate bare badge with { status } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate bare badge with { status } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
|
@ -181,7 +181,7 @@ exports[`test/index.spec.js TAP generate bare badge with { status } > snapshot 1
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate bare badge with { status, color } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate bare badge with { status, color } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
|
@ -199,7 +199,7 @@ exports[`test/index.spec.js TAP generate bare badge with { status, color } > sna
|
|||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP generate bare badge with { status, style } > snapshot 1`] = `
|
||||
exports[`test/badgen.spec.js TAP generate bare badge with { status, style } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect fill="#08C" x="0" width="470" height="200"/>
|
|
@ -0,0 +1,265 @@
|
|||
/* IMPORTANT
|
||||
* This snapshot file is auto-generated, but designed for humans.
|
||||
* It should be checked into source control and tracked carefully.
|
||||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
|
||||
* Make sure to inspect the output below. Do not ignore changes!
|
||||
*/
|
||||
'use strict'
|
||||
exports[`test/badgen.spec.ts TAP ensure badgen() correctly escapes string inputs > snapshot 1`] = `
|
||||
<svg width="191.2" height="20" viewBox="0 0 1912 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="<escape me>: <escape me>">
|
||||
<title><escape me>: <escape me></title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="1912" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="1036" height="200" fill="#<escape me>"/>
|
||||
<rect width="876" height="200" fill="#<escape me>" x="1036"/>
|
||||
<rect width="1912" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="220" y="148" textLength="776" fill="#000" opacity="0.25"><escape me></text>
|
||||
<text x="210" y="138" textLength="776"><escape me></text>
|
||||
<text x="1091" y="148" textLength="776" fill="#000" opacity="0.25"><escape me></text>
|
||||
<text x="1081" y="138" textLength="776"><escape me></text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="<escape me>"/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP ensure bare() correctly escapes string inputs > snapshot 1`] = `
|
||||
<svg width="89.1" height="20" viewBox="0 0 891 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="<escape me>">
|
||||
<title><escape me></title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="891" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="891" height="200" fill="#<escape me>" x="0"/>
|
||||
<rect width="891" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="776" fill="#000" opacity="0.25"><escape me></text>
|
||||
<text x="55" y="138" textLength="776"><escape me></text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate badge with { label, status } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="npm: v1.0.0">
|
||||
<title>npm: v1.0.0</title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="804" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="349" height="200" fill="#555"/>
|
||||
<rect width="455" height="200" fill="#08C" x="349"/>
|
||||
<rect width="804" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="249" fill="#000" opacity="0.25">npm</text>
|
||||
<text x="50" y="138" textLength="249">npm</text>
|
||||
<text x="404" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="394" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate badge with { label, status, color } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="npm: v1.0.0">
|
||||
<title>npm: v1.0.0</title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="804" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="349" height="200" fill="#555"/>
|
||||
<rect width="455" height="200" fill="#ADF" x="349"/>
|
||||
<rect width="804" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="249" fill="#000" opacity="0.25">npm</text>
|
||||
<text x="50" y="138" textLength="249">npm</text>
|
||||
<text x="404" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="394" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate badge with { label, status, color, style } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="npm: v1.0.0">
|
||||
<title>npm: v1.0.0</title>
|
||||
<g>
|
||||
<rect fill="#555" width="349" height="200"/>
|
||||
<rect fill="#ADF" x="349" width="455" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="249" fill="#000" opacity="0.1">npm</text>
|
||||
<text x="50" y="138" textLength="249">npm</text>
|
||||
<text x="404" y="148" textLength="355" fill="#000" opacity="0.1">v1.0.0</text>
|
||||
<text x="394" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate badge with { label, status, icon } > snapshot 1`] = `
|
||||
<svg width="95.5" height="20" viewBox="0 0 955 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="docker: icon">
|
||||
<title>docker: icon</title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="955" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="631" height="200" fill="#555"/>
|
||||
<rect width="324" height="200" fill="#08C" x="631"/>
|
||||
<rect width="955" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="220" y="148" textLength="371" fill="#000" opacity="0.25">docker</text>
|
||||
<text x="210" y="138" textLength="371">docker</text>
|
||||
<text x="686" y="148" textLength="224" fill="#000" opacity="0.25">icon</text>
|
||||
<text x="676" y="138" textLength="224">icon</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNGRkYiIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgPHBhdGggZD0iTTE2LjIxIDguNjlsNi43Mi0xLjY4QTEyLjAzIDEyLjAzIDAgMCAxIDI0IDExLjk3YTEyLjA5IDEyLjA5IDAgMCAxLTEyLjk0IDEybDQuOS04LjM1Yy4zNi0uMzguNjYtLjguODktMS4yN2E1LjQ1IDUuNDUgMCAwIDAtLjA1LTQuNzUgNS4xNiA1LjE2IDAgMCAwLS41OS0uOTF6bS0zLjI0IDguNTdsLTIuMTIgNi42OUExMi4wMiAxMi4wMiAwIDAgMSAyLjA0IDUuMjhsNC44MyA4LjM4Yy4xOC41NCAxLjEyIDIuNTggMy4wNyAzLjMyIDEgLjM5IDIuMDQuNDggMy4wMy4yOXptLTEtOS42NGE0LjUyIDQuNTIgMCAwIDAtNC4yOCAzLjUxIDQuNDggNC40OCAwIDAgMCAxLjI0IDQuMDMgNC40OSA0LjQ5IDAgMCAwIDQuNzMuOTMgNC40OSA0LjQ5IDAgMCAwIDIuNy0zLjQzIDQuNTMgNC41MyAwIDAgMC0yLjUtNC42MyA0LjQxIDQuNDEgMCAwIDAtMS44OS0uNDF6TTcuMDUgOS45NmwtNC44LTVBMTIuMDQgMTIuMDQgMCAwIDEgMTIgMGM0LjU2IDAgOC43NCAyLjYgMTAuNzcgNi42N0gxMi41NmE1LjU0IDUuNTQgMCAwIDAtNC4yNyAxLjQ2IDUuMzQgNS4zNCAwIDAgMC0xLjI0IDEuODN6Ii8+Cjwvc3ZnPgo="/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate badge with { label, status, icon, style } > snapshot 1`] = `
|
||||
<svg width="95.5" height="20" viewBox="0 0 955 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="docker: icon">
|
||||
<title>docker: icon</title>
|
||||
<g>
|
||||
<rect fill="#555" width="631" height="200"/>
|
||||
<rect fill="#08C" x="631" width="324" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="220" y="148" textLength="371" fill="#000" opacity="0.1">docker</text>
|
||||
<text x="210" y="138" textLength="371">docker</text>
|
||||
<text x="686" y="148" textLength="224" fill="#000" opacity="0.1">icon</text>
|
||||
<text x="676" y="138" textLength="224">icon</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="132" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNDAuOTI1IiBoZWlnaHQ9IjIwMi42NzYiIHZpZXdCb3g9IjAgMCA5MC4yMDMgNTMuNjI1Ij48ZyBmaWxsPSIjZmZmIj48cGF0aCBvcGFjaXR5PSIuNDU2IiBkPSJNNDUuMjE2IDMuODI2Yy0xMi44MzYgMC0yMi4yOCAzLjYzNC0yNi44ODQgMTAuNTMxLS4wOTEtLjEwNi0uMTcxLS4xNzItLjI2Ni0uMzAyLS40NTktLjYyOS0uOTQ1LTEuNDg2LTEuNDI4LTIuMzg0LS40ODQtLjg5OC0uOTY3LTEuODM1LTEuNDg1LTIuNjctLjUxOC0uODM1LTEuMDI1LTEuNTkzLTEuODc0LTIuMTE2LS45MjctLjU3My0xLjczMy0uODI4LTIuMzQ3LS45MTZhMy42ODMgMy42ODMgMCAwIDAtLjg2Mi0uMDE1Yy0xLjUzNS4wMDYtMi43MTQgMS4wMTgtMy42MiAyLjI1NS0uOTEgMS4yNDEtMS42MDkgMi44MzUtMi4wNDIgNC41ODYtLjg2NiAzLjQ5OS0uNzAzIDcuNzU4IDIuMDU2IDEwLjU2IDEuNDYgMS40OTMgMy40MDQgMi4zNSA1LjI2NSAyLjg1IDEuMzIuMzU1IDIuNTMuNDc4IDMuNjI5LjUwOS42MDggNy4xMzMgNC43OTcgMTMuNDA2IDEwLjM5IDE2LjU1OWguMDAxYzIuOTg1IDEuNjc3IDYuMDg0IDIuNTM4IDguNzk5IDMuNTc3IDMu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LjA1OG0xNi40NzYtMjcuMDgxYy02LjMzNiAwLTExLjQ3MiA1LjEzNy0xMS40NzIgMTEuNDczIDAgNi4zMzYgNS4xMzYgMTEuNDczIDExLjQ3MiAxMS40NzMgNi4zMzYgMCAxMS40NzMtNS4xMzcgMTEuNDczLTExLjQ3MyAwLTYuMzM2LTUuMTM3LTExLjQ3My0xMS40NzMtMTEuNDczem0tMS42MDYgNi40NGE1LjEgNS4xIDAgMCAxIDAgMTAuMTk3IDUuMDk4IDUuMDk4IDAgMCAxLTQuOTM4LTYuMzY3IDIuMTQ0IDIuMTQ0IDAgMSAwIDIuMDc0LTIuOTUgNS4wNzIgNS4wNzIgMCAwIDEgMi44NjQtLjg4em0tMjcuNTI1LTYuNDRjLTYuMzM2IDAtMTEuNDcyIDUuMTM3LTExLjQ3MiAxMS40NzMgMCA2LjMzNiA1LjEzNiAxMS40NzMgMTEuNDcyIDExLjQ3MyA2LjMzNiAwIDExLjQ3My01LjEzNyAxMS40NzMtMTEuNDczIDAtNi4zMzYtNS4xMzctMTEuNDczLTExLjQ3My0xMS40NzN6bTEuNjQgNi40NGE1LjEgNS4xIDAgMCAxIDAgMTAuMTk3IDUuMDk4IDUuMDk4IDAgMCAxLTQuOTM4LTYuMzY3IDIuMTQ0IDIuMTQ0IDAgMCAwIDQuMTI3LS44MSAyLjE0MiAyLjE0MiAwIDAgMC0yLjA1NC0yLjE0IDUuMDc0IDUuMDc0IDAgMCAxIDIuODY0LS44OHoiLz48L2c+PC9zdmc+"/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate badge with { label, status, style } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="npm: v1.0.0">
|
||||
<title>npm: v1.0.0</title>
|
||||
<g>
|
||||
<rect fill="#555" width="349" height="200"/>
|
||||
<rect fill="#08C" x="349" width="455" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="249" fill="#000" opacity="0.1">npm</text>
|
||||
<text x="50" y="138" textLength="249">npm</text>
|
||||
<text x="404" y="148" textLength="355" fill="#000" opacity="0.1">v1.0.0</text>
|
||||
<text x="394" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate badge with { status, icon } > snapshot 1`] = `
|
||||
<svg width="53.6" height="20" viewBox="0 0 536 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="icon">
|
||||
<title>icon</title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="536" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="212" height="200" fill="#555"/>
|
||||
<rect width="324" height="200" fill="#08C" x="212"/>
|
||||
<rect width="536" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="172" y="148" textLength="0" fill="#000" opacity="0.25"></text>
|
||||
<text x="162" y="138" textLength="0"></text>
|
||||
<text x="267" y="148" textLength="224" fill="#000" opacity="0.25">icon</text>
|
||||
<text x="257" y="138" textLength="224">icon</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNGRkYiIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgPHBhdGggZD0iTTE2LjIxIDguNjlsNi43Mi0xLjY4QTEyLjAzIDEyLjAzIDAgMCAxIDI0IDExLjk3YTEyLjA5IDEyLjA5IDAgMCAxLTEyLjk0IDEybDQuOS04LjM1Yy4zNi0uMzguNjYtLjguODktMS4yN2E1LjQ1IDUuNDUgMCAwIDAtLjA1LTQuNzUgNS4xNiA1LjE2IDAgMCAwLS41OS0uOTF6bS0zLjI0IDguNTdsLTIuMTIgNi42OUExMi4wMiAxMi4wMiAwIDAgMSAyLjA0IDUuMjhsNC44MyA4LjM4Yy4xOC41NCAxLjEyIDIuNTggMy4wNyAzLjMyIDEgLjM5IDIuMDQuNDggMy4wMy4yOXptLTEtOS42NGE0LjUyIDQuNTIgMCAwIDAtNC4yOCAzLjUxIDQuNDggNC40OCAwIDAgMCAxLjI0IDQuMDMgNC40OSA0LjQ5IDAgMCAwIDQuNzMuOTMgNC40OSA0LjQ5IDAgMCAwIDIuNy0zLjQzIDQuNTMgNC41MyAwIDAgMC0yLjUtNC42MyA0LjQxIDQuNDEgMCAwIDAtMS44OS0uNDF6TTcuMDUgOS45NmwtNC44LTVBMTIuMDQgMTIuMDQgMCAwIDEgMTIgMGM0LjU2IDAgOC43NCAyLjYgMTAuNzcgNi42N0gxMi41NmE1LjU0IDUuNTQgMCAwIDAtNC4yNyAxLjQ2IDUuMzQgNS4zNCAwIDAgMC0xLjI0IDEuODN6Ii8+Cjwvc3ZnPgo="/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate badge with { status, icon, iconWidth } > snapshot 1`] = `
|
||||
<svg width="59.6" height="20" viewBox="0 0 596 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="icon">
|
||||
<title>icon</title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="596" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="272" height="200" fill="#555"/>
|
||||
<rect width="324" height="200" fill="#08C" x="272"/>
|
||||
<rect width="596" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="232" y="148" textLength="0" fill="#000" opacity="0.25"></text>
|
||||
<text x="222" y="138" textLength="0"></text>
|
||||
<text x="327" y="148" textLength="224" fill="#000" opacity="0.25">icon</text>
|
||||
<text x="317" y="138" textLength="224">icon</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="190" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNDAuOTI1IiBoZWlnaHQ9IjIwMi42NzYiIHZpZXdCb3g9IjAgMCA5MC4yMDMgNTMuNjI1Ij48ZyBmaWxsPSIjZmZmIj48cGF0aCBvcGFjaXR5PSIuNDU2IiBkPSJNNDUuMjE2IDMuODI2Yy0xMi44MzYgMC0yMi4yOCAzLjYzNC0yNi44ODQgMTAuNTMxLS4wOTEtLjEwNi0uMTcxLS4xNzItLjI2Ni0uMzAyLS40NTktLjYyOS0uOTQ1LTEuNDg2LTEuNDI4LTIuMzg0LS40ODQtLjg5OC0uOTY3LTEuODM1LTEuNDg1LTIuNjctLjUxOC0uODM1LTEuMDI1LTEuNTkzLTEuODc0LTIuMTE2LS45MjctLjU3My0xLjczMy0uODI4LTIuMzQ3LS45MTZhMy42ODMgMy42ODMgMCAwIDAtLjg2Mi0uMDE1Yy0xLjUzNS4wMDYtMi43MTQgMS4wMTgtMy42MiAyLjI1NS0uOTEgMS4yNDEtMS42MDkgMi44MzUtMi4wNDIgNC41ODYtLjg2NiAzLjQ5OS0uNzAzIDcuNzU4IDIuMDU2IDEwLjU2IDEuNDYgMS40OTMgMy40MDQgMi4zNSA1LjI2NSAyLjg1IDEuMzIuMzU1IDIuNTMu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jgyLS4wNTQuNjMzLS4zNDcuNjc0LS42ODYuMDk3LS42ODYuMjE2LS42ODYuNTY2IDAgLjM0OC40MDMuNDk0LjQ4Ni41MTNhLjUzNi41MzYgMCAwIDEtLjEyMiAxLjA1OG0xNi40NzYtMjcuMDgxYy02LjMzNiAwLTExLjQ3MiA1LjEzNy0xMS40NzIgMTEuNDczIDAgNi4zMzYgNS4xMzYgMTEuNDczIDExLjQ3MiAxMS40NzMgNi4zMzYgMCAxMS40NzMtNS4xMzcgMTEuNDczLTExLjQ3MyAwLTYuMzM2LTUuMTM3LTExLjQ3My0xMS40NzMtMTEuNDczem0tMS42MDYgNi40NGE1LjEgNS4xIDAgMCAxIDAgMTAuMTk3IDUuMDk4IDUuMDk4IDAgMCAxLTQuOTM4LTYuMzY3IDIuMTQ0IDIuMTQ0IDAgMSAwIDIuMDc0LTIuOTUgNS4wNzIgNS4wNzIgMCAwIDEgMi44NjQtLjg4em0tMjcuNTI1LTYuNDRjLTYuMzM2IDAtMTEuNDcyIDUuMTM3LTExLjQ3MiAxMS40NzMgMCA2LjMzNiA1LjEzNiAxMS40NzMgMTEuNDcyIDExLjQ3MyA2LjMzNiAwIDExLjQ3My01LjEzNyAxMS40NzMtMTEuNDczIDAtNi4zMzYtNS4xMzctMTEuNDczLTExLjQ3My0xMS40NzN6bTEuNjQgNi40NGE1LjEgNS4xIDAgMCAxIDAgMTAuMTk3IDUuMDk4IDUuMDk4IDAgMCAxLTQuOTM4LTYuMzY3IDIuMTQ0IDIuMTQ0IDAgMCAwIDQuMTI3LS44MSAyLjE0MiAyLjE0MiAwIDAgMC0yLjA1NC0yLjE0IDUuMDc0IDUuMDc0IDAgMCAxIDIuODY0LS44OHoiLz48L2c+PC9zdmc+"/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate bare badge with { status } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="v1.0.0">
|
||||
<title>v1.0.0</title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="470" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="470" height="200" fill="#08C" x="0"/>
|
||||
<rect width="470" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate bare badge with { status, color } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="v1.0.0">
|
||||
<title>v1.0.0</title>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="470" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="470" height="200" fill="#ADF" x="0"/>
|
||||
<rect width="470" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.ts TAP generate bare badge with { status, style } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="v1.0.0">
|
||||
<title>v1.0.0</title>
|
||||
<g>
|
||||
<rect fill="#08C" x="0" width="470" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.1">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
|
@ -1,54 +0,0 @@
|
|||
/* IMPORTANT
|
||||
* This snapshot file is auto-generated, but designed for humans.
|
||||
* It should be checked into source control and tracked carefully.
|
||||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
|
||||
* Make sure to inspect the output below. Do not ignore changes!
|
||||
*/
|
||||
'use strict'
|
||||
exports[`test/bare.spec.js TAP generate bare badge with { status } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="470" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="470" height="200" fill="#08C" x="0"/>
|
||||
<rect width="470" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/bare.spec.js TAP generate bare badge with { status, color } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="470" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="470" height="200" fill="#ADF" x="0"/>
|
||||
<rect width="470" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/bare.spec.js TAP generate bare badge with { status, style } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect fill="#08C" x="0" width="470" height="200"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.1">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
|
@ -1,22 +0,0 @@
|
|||
/* IMPORTANT
|
||||
* This snapshot file is auto-generated, but designed for humans.
|
||||
* It should be checked into source control and tracked carefully.
|
||||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
|
||||
* Make sure to inspect the output below. Do not ignore changes!
|
||||
*/
|
||||
'use strict'
|
||||
exports[`test/calc-text-width.spec.js TAP calc width for "npm" > result is correct 1`] = `
|
||||
249
|
||||
`
|
||||
|
||||
exports[`test/calc-text-width.spec.js TAP calc width for emojis > result is correct 1`] = `
|
||||
330
|
||||
`
|
||||
|
||||
exports[`test/calc-text-width.spec.js TAP calc width for special chars > result is correct 1`] = `
|
||||
600
|
||||
`
|
||||
|
||||
exports[`test/calc-text-width.spec.js TAP calc width for unicode > result is correct 1`] = `
|
||||
550
|
||||
`
|
|
@ -0,0 +1,22 @@
|
|||
/* IMPORTANT
|
||||
* This snapshot file is auto-generated, but designed for humans.
|
||||
* It should be checked into source control and tracked carefully.
|
||||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
|
||||
* Make sure to inspect the output below. Do not ignore changes!
|
||||
*/
|
||||
'use strict'
|
||||
exports[`test/calc-width.spec.ts TAP calc width for "npm" > result is correct 1`] = `
|
||||
249
|
||||
`
|
||||
|
||||
exports[`test/calc-width.spec.ts TAP calc width for emojis > result is correct 1`] = `
|
||||
330
|
||||
`
|
||||
|
||||
exports[`test/calc-width.spec.ts TAP calc width for special chars > result is correct 1`] = `
|
||||
600
|
||||
`
|
||||
|
||||
exports[`test/calc-width.spec.ts TAP calc width for unicode > result is correct 1`] = `
|
||||
550
|
||||
`
|
|
@ -0,0 +1,265 @@
|
|||
/* IMPORTANT
|
||||
* This snapshot file is auto-generated, but designed for humans.
|
||||
* It should be checked into source control and tracked carefully.
|
||||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
|
||||
* Make sure to inspect the output below. Do not ignore changes!
|
||||
*/
|
||||
'use strict'
|
||||
exports[`test/badgen.spec.js TAP ensure badgen() correctly escapes string inputs > snapshot 1`] = `
|
||||
<svg width="191.2" height="20" viewBox="0 0 1912 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="<escape me>: <escape me>">
|
||||
<title><escape me>: <escape me></title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="1912" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="1036" height="200" fill="#<escape me>"/>
|
||||
<rect width="876" height="200" fill="#<escape me>" x="1036"/>
|
||||
<rect width="1912" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="220" y="148" textLength="776" fill="#000" opacity="0.25"><escape me></text>
|
||||
<text x="210" y="138" textLength="776"><escape me></text>
|
||||
<text x="1091" y="148" textLength="776" fill="#000" opacity="0.25"><escape me></text>
|
||||
<text x="1081" y="138" textLength="776"><escape me></text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="<escape me>"/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP ensure bare() correctly escapes string inputs > snapshot 1`] = `
|
||||
<svg width="89.1" height="20" viewBox="0 0 891 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="<escape me>">
|
||||
<title><escape me></title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="891" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="891" height="200" fill="#<escape me>" x="0"/>
|
||||
<rect width="891" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="776" fill="#000" opacity="0.25"><escape me></text>
|
||||
<text x="55" y="138" textLength="776"><escape me></text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="npm: v1.0.0">
|
||||
<title>npm: v1.0.0</title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="804" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="349" height="200" fill="#555"/>
|
||||
<rect width="455" height="200" fill="#08C" x="349"/>
|
||||
<rect width="804" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="249" fill="#000" opacity="0.25">npm</text>
|
||||
<text x="50" y="138" textLength="249">npm</text>
|
||||
<text x="404" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="394" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, color } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="npm: v1.0.0">
|
||||
<title>npm: v1.0.0</title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="804" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="349" height="200" fill="#555"/>
|
||||
<rect width="455" height="200" fill="#ADF" x="349"/>
|
||||
<rect width="804" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="249" fill="#000" opacity="0.25">npm</text>
|
||||
<text x="50" y="138" textLength="249">npm</text>
|
||||
<text x="404" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="394" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, color, style } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="npm: v1.0.0">
|
||||
<title>npm: v1.0.0</title>
|
||||
<g>
|
||||
<rect fill="#555" width="349" height="200"/>
|
||||
<rect fill="#ADF" x="349" width="455" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="249" fill="#000" opacity="0.1">npm</text>
|
||||
<text x="50" y="138" textLength="249">npm</text>
|
||||
<text x="404" y="148" textLength="355" fill="#000" opacity="0.1">v1.0.0</text>
|
||||
<text x="394" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, icon } > snapshot 1`] = `
|
||||
<svg width="95.5" height="20" viewBox="0 0 955 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="docker: icon">
|
||||
<title>docker: icon</title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="955" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="631" height="200" fill="#555"/>
|
||||
<rect width="324" height="200" fill="#08C" x="631"/>
|
||||
<rect width="955" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="220" y="148" textLength="371" fill="#000" opacity="0.25">docker</text>
|
||||
<text x="210" y="138" textLength="371">docker</text>
|
||||
<text x="686" y="148" textLength="224" fill="#000" opacity="0.25">icon</text>
|
||||
<text x="676" y="138" textLength="224">icon</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNGRkYiIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgPHBhdGggZD0iTTE2LjIxIDguNjlsNi43Mi0xLjY4QTEyLjAzIDEyLjAzIDAgMCAxIDI0IDExLjk3YTEyLjA5IDEyLjA5IDAgMCAxLTEyLjk0IDEybDQuOS04LjM1Yy4zNi0uMzguNjYtLjguODktMS4yN2E1LjQ1IDUuNDUgMCAwIDAtLjA1LTQuNzUgNS4xNiA1LjE2IDAgMCAwLS41OS0uOTF6bS0zLjI0IDguNTdsLTIuMTIgNi42OUExMi4wMiAxMi4wMiAwIDAgMSAyLjA0IDUuMjhsNC44MyA4LjM4Yy4xOC41NCAxLjEyIDIuNTggMy4wNyAzLjMyIDEgLjM5IDIuMDQuNDggMy4wMy4yOXptLTEtOS42NGE0LjUyIDQuNTIgMCAwIDAtNC4yOCAzLjUxIDQuNDggNC40OCAwIDAgMCAxLjI0IDQuMDMgNC40OSA0LjQ5IDAgMCAwIDQuNzMuOTMgNC40OSA0LjQ5IDAgMCAwIDIuNy0zLjQzIDQuNTMgNC41MyAwIDAgMC0yLjUtNC42MyA0LjQxIDQuNDEgMCAwIDAtMS44OS0uNDF6TTcuMDUgOS45NmwtNC44LTVBMTIuMDQgMTIuMDQgMCAwIDEgMTIgMGM0LjU2IDAgOC43NCAyLjYgMTAuNzcgNi42N0gxMi41NmE1LjU0IDUuNTQgMCAwIDAtNC4yNyAxLjQ2IDUuMzQgNS4zNCAwIDAgMC0xLjI0IDEuODN6Ii8+Cjwvc3ZnPgo="/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, icon, style } > snapshot 1`] = `
|
||||
<svg width="95.5" height="20" viewBox="0 0 955 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="docker: icon">
|
||||
<title>docker: icon</title>
|
||||
<g>
|
||||
<rect fill="#555" width="631" height="200"/>
|
||||
<rect fill="#08C" x="631" width="324" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="220" y="148" textLength="371" fill="#000" opacity="0.1">docker</text>
|
||||
<text x="210" y="138" textLength="371">docker</text>
|
||||
<text x="686" y="148" textLength="224" fill="#000" opacity="0.1">icon</text>
|
||||
<text x="676" y="138" textLength="224">icon</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="132" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNDAuOTI1IiBoZWlnaHQ9IjIwMi42NzYiIHZpZXdCb3g9IjAgMCA5MC4yMDMgNTMuNjI1Ij48ZyBmaWxsPSIjZmZmIj48cGF0aCBvcGFjaXR5PSIuNDU2IiBkPSJNNDUuMjE2IDMuODI2Yy0xMi44MzYgMC0yMi4yOCAzLjYzNC0yNi44ODQgMTAuNTMxLS4wOTEtLjEwNi0uMTcxLS4xNzItLjI2Ni0uMzAyLS40NTktLjYyOS0uOTQ1LTEuNDg2LTEuNDI4LTIuMzg0LS40ODQtLjg5OC0uOTY3LTEuODM1LTEuNDg1LTIuNjctLjUxOC0uODM1LTEuMDI1LTEuNTkzLTEuODc0LTIuMTE2LS45MjctLjU3My0xLjczMy0uODI4LTIuMzQ3LS45MTZhMy42ODMgMy42ODM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MiAyLjE0MiAwIDAgMC0yLjA1NC0yLjE0IDUuMDc0IDUuMDc0IDAgMCAxIDIuODY0LS44OHoiLz48L2c+PC9zdmc+"/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate badge with { label, status, style } > snapshot 1`] = `
|
||||
<svg width="80.4" height="20" viewBox="0 0 804 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="npm: v1.0.0">
|
||||
<title>npm: v1.0.0</title>
|
||||
<g>
|
||||
<rect fill="#555" width="349" height="200"/>
|
||||
<rect fill="#08C" x="349" width="455" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="249" fill="#000" opacity="0.1">npm</text>
|
||||
<text x="50" y="138" textLength="249">npm</text>
|
||||
<text x="404" y="148" textLength="355" fill="#000" opacity="0.1">v1.0.0</text>
|
||||
<text x="394" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate badge with { status, icon } > snapshot 1`] = `
|
||||
<svg width="53.6" height="20" viewBox="0 0 536 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="icon">
|
||||
<title>icon</title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="536" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="212" height="200" fill="#555"/>
|
||||
<rect width="324" height="200" fill="#08C" x="212"/>
|
||||
<rect width="536" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="172" y="148" textLength="0" fill="#000" opacity="0.25"></text>
|
||||
<text x="162" y="138" textLength="0"></text>
|
||||
<text x="267" y="148" textLength="224" fill="#000" opacity="0.25">icon</text>
|
||||
<text x="257" y="138" textLength="224">icon</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNGRkYiIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgPHBhdGggZD0iTTE2LjIxIDguNjlsNi43Mi0xLjY4QTEyLjAzIDEyLjAzIDAgMCAxIDI0IDExLjk3YTEyLjA5IDEyLjA5IDAgMCAxLTEyLjk0IDEybDQuOS04LjM1Yy4zNi0uMzguNjYtLjguODktMS4yN2E1LjQ1IDUuNDUgMCAwIDAtLjA1LTQuNzUgNS4xNiA1LjE2IDAgMCAwLS41OS0uOTF6bS0zLjI0IDguNTdsLTIuMTIgNi42OUExMi4wMiAxMi4wMiAwIDAgMSAyLjA0IDUuMjhsNC44MyA4LjM4Yy4xOC41NCAxLjEyIDIuNTggMy4wNyAzLjMyIDEgLjM5IDIuMDQuNDggMy4wMy4yOXptLTEtOS42NGE0LjUyIDQuNTIgMCAwIDAtNC4yOCAzLjUxIDQuNDggNC40OCAwIDAgMCAxLjI0IDQuMDMgNC40OSA0LjQ5IDAgMCAwIDQuNzMuOTMgNC40OSA0LjQ5IDAgMCAwIDIuNy0zLjQzIDQuNTMgNC41MyAwIDAgMC0yLjUtNC42MyA0LjQxIDQuNDEgMCAwIDAtMS44OS0uNDF6TTcuMDUgOS45NmwtNC44LTVBMTIuMDQgMTIuMDQgMCAwIDEgMTIgMGM0LjU2IDAgOC43NCAyLjYgMTAuNzcgNi42N0gxMi41NmE1LjU0IDUuNTQgMCAwIDAtNC4yNyAxLjQ2IDUuMzQgNS4zNCAwIDAgMC0xLjI0IDEuODN6Ii8+Cjwvc3ZnPgo="/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate badge with { status, icon, iconWidth } > snapshot 1`] = `
|
||||
<svg width="59.6" height="20" viewBox="0 0 596 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" role="img" aria-label="icon">
|
||||
<title>icon</title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="596" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="272" height="200" fill="#555"/>
|
||||
<rect width="324" height="200" fill="#08C" x="272"/>
|
||||
<rect width="596" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="232" y="148" textLength="0" fill="#000" opacity="0.25"></text>
|
||||
<text x="222" y="138" textLength="0"></text>
|
||||
<text x="327" y="148" textLength="224" fill="#000" opacity="0.25">icon</text>
|
||||
<text x="317" y="138" textLength="224">icon</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="190" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzNDAuOTI1IiBoZWlnaHQ9IjIwMi42NzYiIHZpZXdCb3g9IjAgMCA5MC4yMDMgNTMuNjI1Ij48ZyBmaWxsPSIjZmZmIj48cGF0aCBvcGFjaXR5PSIuNDU2IiBkPSJNNDUuMjE2IDMuODI2Yy0xMi44MzYgMC0yMi4yOCAzLjYzNC0yNi44ODQgMTAuNTMxLS4wOTEtLjEwNi0uMTcxLS4xNzItLjI2Ni0uMzAyLS40NTktLjYyOS0uOTQ1LTEuNDg2LTE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DczLTExLjQ3My0xMS40NzN6bTEuNjQgNi40NGE1LjEgNS4xIDAgMCAxIDAgMTAuMTk3IDUuMDk4IDUuMDk4IDAgMCAxLTQuOTM4LTYuMzY3IDIuMTQ0IDIuMTQ0IDAgMCAwIDQuMTI3LS44MSAyLjE0MiAyLjE0MiAwIDAgMC0yLjA1NC0yLjE0IDUuMDc0IDUuMDc0IDAgMCAxIDIuODY0LS44OHoiLz48L2c+PC9zdmc+"/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate bare badge with { status } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="v1.0.0">
|
||||
<title>v1.0.0</title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="470" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="470" height="200" fill="#08C" x="0"/>
|
||||
<rect width="470" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate bare badge with { status, color } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="v1.0.0">
|
||||
<title>v1.0.0</title>
|
||||
<linearGradient id="aaaaa" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="aaaaa"><rect width="470" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#aaaaa)">
|
||||
<rect width="470" height="200" fill="#ADF" x="0"/>
|
||||
<rect width="470" height="200" fill="url(#aaaaa)"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.25">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/badgen.spec.js TAP generate bare badge with { status, style } > snapshot 1`] = `
|
||||
<svg width="47" height="20" viewBox="0 0 470 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="v1.0.0">
|
||||
<title>v1.0.0</title>
|
||||
<g>
|
||||
<rect fill="#08C" x="0" width="470" height="200"/>
|
||||
</g>
|
||||
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="355" fill="#000" opacity="0.1">v1.0.0</text>
|
||||
<text x="55" y="138" textLength="355">v1.0.0</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
|
@ -0,0 +1,22 @@
|
|||
/* IMPORTANT
|
||||
* This snapshot file is auto-generated, but designed for humans.
|
||||
* It should be checked into source control and tracked carefully.
|
||||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
|
||||
* Make sure to inspect the output below. Do not ignore changes!
|
||||
*/
|
||||
'use strict'
|
||||
exports[`test/calc-width.spec.js TAP calc width for "npm" > result is correct 1`] = `
|
||||
249
|
||||
`
|
||||
|
||||
exports[`test/calc-width.spec.js TAP calc width for emojis > result is correct 1`] = `
|
||||
330
|
||||
`
|
||||
|
||||
exports[`test/calc-width.spec.js TAP calc width for special chars > result is correct 1`] = `
|
||||
600
|
||||
`
|
||||
|
||||
exports[`test/calc-width.spec.js TAP calc width for unicode > result is correct 1`] = `
|
||||
550
|
||||
`
|
|
@ -1,7 +1,14 @@
|
|||
const tap = require('tap')
|
||||
const badgen = require('../src/index.js')
|
||||
const { badgen } = require('../dist')
|
||||
const icons = require('./assets/icon-data-uri.js')
|
||||
|
||||
const originalMath = global.Math
|
||||
const mockMath = Object.create(global.Math)
|
||||
mockMath.random = () => 0.5
|
||||
|
||||
tap.beforeEach(async t => { global.Math = mockMath })
|
||||
tap.afterEach(async t => { global.Math = originalMath })
|
||||
|
||||
tap.test('generate badge with { label, status }', t => {
|
||||
const svg = badgen({ label: 'npm', status: 'v1.0.0' })
|
||||
t.ok(typeof svg === 'string', 'successfully generated')
|
||||
|
@ -54,6 +61,18 @@ tap.test('generate badge with { label, status, icon, style }', t => {
|
|||
t.end()
|
||||
})
|
||||
|
||||
tap.test('ensure badgen() correctly escapes string inputs', t => {
|
||||
const svg = badgen({
|
||||
label: '<escape me>',
|
||||
status: '<escape me>',
|
||||
color: '<escape me>',
|
||||
icon: '<escape me>',
|
||||
labelColor: '<escape me>',
|
||||
})
|
||||
t.matchSnapshot(svg, 'snapshot')
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('generate bare badge with { status }', t => {
|
||||
const svg = badgen({ status: 'v1.0.0' })
|
||||
t.ok(typeof svg === 'string', 'successfully generated')
|
||||
|
@ -75,7 +94,17 @@ tap.test('generate bare badge with { status, style }', t => {
|
|||
t.end()
|
||||
})
|
||||
|
||||
tap.test('ensure bare() correctly escapes string inputs', t => {
|
||||
const svg = badgen({
|
||||
status: '<escape me>',
|
||||
color: '<escape me>',
|
||||
})
|
||||
t.matchSnapshot(svg, 'snapshot')
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('type checking', t => {
|
||||
// @ts-ignore
|
||||
t.throws(() => badgen({}), TypeError, 'throw if status is non-string')
|
||||
t.end()
|
||||
})
|
|
@ -1,5 +1,5 @@
|
|||
const tap = require('tap')
|
||||
const calcWidth = require('../src/calc-text-width.js').Verdana110
|
||||
const { calcWidth } = require('../dist')
|
||||
|
||||
tap.test('basic functions', t => {
|
||||
t.ok(typeof calcWidth === 'function', 'export calcWidth function')
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
|
||||
"target": "es2017",
|
||||
"module": "commonjs",
|
||||
"lib": ["esnext", "dom"],
|
||||
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
|
||||
"sourceMap":true,
|
||||
"declaration": true,
|
||||
|
||||
"resolveJsonModule": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
Ładowanie…
Reference in New Issue