- With examples using `pattern`s, allow building the URL from its component parts, including the query string. - Provide a button to copy the link, with an animation. To enable this for other badges, convert them to use a `pattern`: #1961.
29 lines
683 B
JavaScript
29 lines
683 B
JavaScript
import PathBuilder from './path-builder'
|
|
import { test, given } from 'sazerac'
|
|
import pathToRegexp from 'path-to-regexp'
|
|
|
|
describe('<PathBuilder />', function() {
|
|
const tokens = pathToRegexp.parse('github/license/:user/:repo')
|
|
test(PathBuilder.constructPath, () => {
|
|
given({
|
|
tokens,
|
|
namedParams: {
|
|
user: 'paulmelnikow',
|
|
repo: 'react-boxplot',
|
|
},
|
|
}).expect({
|
|
path: 'github/license/paulmelnikow/react-boxplot',
|
|
isComplete: true,
|
|
})
|
|
given({
|
|
tokens,
|
|
namedParams: {
|
|
user: 'paulmelnikow',
|
|
},
|
|
}).expect({
|
|
path: 'github/license/paulmelnikow/:repo',
|
|
isComplete: false,
|
|
})
|
|
})
|
|
})
|