Examples: Drop deprecated aliases query, urlPattern (#2443)
This commit is contained in:
@@ -53,13 +53,13 @@ module.exports = class AppVeyorTests extends AppVeyorBase {
|
||||
{
|
||||
title: 'AppVeyor tests (compact)',
|
||||
previewUrl: 'NZSmartie/coap-net-iu0to',
|
||||
query: { compact_message: null },
|
||||
queryParams: { compact_message: null },
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'AppVeyor tests with custom labels',
|
||||
previewUrl: 'NZSmartie/coap-net-iu0to',
|
||||
query: {
|
||||
queryParams: {
|
||||
passed_label: 'good',
|
||||
failed_label: 'bad',
|
||||
skipped_label: 'n/a',
|
||||
|
||||
@@ -119,7 +119,7 @@ module.exports = class AzureDevOpsTests extends BaseAzureDevOpsService {
|
||||
title: 'Azure DevOps tests (compact)',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
exampleUrl: 'azuredevops-powershell/azuredevops-powershell/1',
|
||||
query: {
|
||||
queryParams: {
|
||||
compact_message: null,
|
||||
},
|
||||
keywords: ['vso', 'vsts', 'azure-devops'],
|
||||
@@ -137,7 +137,7 @@ module.exports = class AzureDevOpsTests extends BaseAzureDevOpsService {
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
exampleUrl: 'azuredevops-powershell/azuredevops-powershell/1',
|
||||
keywords: ['vso', 'vsts', 'azure-devops'],
|
||||
query: {
|
||||
queryParams: {
|
||||
passed_label: 'good',
|
||||
failed_label: 'bad',
|
||||
skipped_label: 'n/a',
|
||||
|
||||
@@ -103,9 +103,7 @@ class BaseService {
|
||||
* substitute into the compiled route pattern.
|
||||
* queryParams: An object containing query parameters to include in the
|
||||
* example URLs.
|
||||
* query: Deprecated. An alias for `queryParams`.
|
||||
* pattern: The route pattern to compile. Defaults to `this.route.pattern`.
|
||||
* urlPattern: Deprecated. An alias for `pattern`.
|
||||
* staticPreview: A rendered badge of the sort returned by `handle()` or
|
||||
* `render()`: an object containing `message` and optional `label` and
|
||||
* `color`. This is usually generated by invoking `this.render()` with some
|
||||
|
||||
@@ -35,13 +35,7 @@ class DummyService extends BaseService {
|
||||
static get examples() {
|
||||
return [
|
||||
{ previewUrl: 'World' },
|
||||
{ previewUrl: 'World', query: { queryParamA: '!!!' } },
|
||||
{
|
||||
urlPattern: ':world',
|
||||
exampleUrl: 'World',
|
||||
staticExample: this.render({ namedParamA: 'foo', queryParamA: 'bar' }),
|
||||
keywords: ['hello'],
|
||||
},
|
||||
{ previewUrl: 'World', queryParams: { queryParamA: '!!!' } },
|
||||
{
|
||||
pattern: ':world',
|
||||
exampleUrl: 'World',
|
||||
@@ -57,7 +51,7 @@ class DummyService extends BaseService {
|
||||
{
|
||||
pattern: ':world',
|
||||
namedParams: { world: 'World' },
|
||||
query: { queryParamA: '!!!' },
|
||||
queryParams: { queryParamA: '!!!' },
|
||||
staticExample: this.render({ namedParamA: 'foo', queryParamA: 'bar' }),
|
||||
keywords: ['hello'],
|
||||
},
|
||||
@@ -476,7 +470,6 @@ describe('BaseService', function() {
|
||||
third,
|
||||
fourth,
|
||||
fifth,
|
||||
sixth,
|
||||
] = DummyService.prepareExamples()
|
||||
expect(first).to.deep.equal({
|
||||
title: 'DummyService',
|
||||
@@ -505,8 +498,7 @@ describe('BaseService', function() {
|
||||
}
|
||||
expect(third).to.deep.equal(preparedStaticExample)
|
||||
expect(fourth).to.deep.equal(preparedStaticExample)
|
||||
expect(fifth).to.deep.equal(preparedStaticExample)
|
||||
expect(sixth).to.deep.equal({
|
||||
expect(fifth).to.deep.equal({
|
||||
title: 'DummyService',
|
||||
exampleUrl: '/foo/World.svg?queryParamA=%21%21%21',
|
||||
previewUrl:
|
||||
@@ -521,7 +513,7 @@ describe('BaseService', function() {
|
||||
describe('getDefinition', function() {
|
||||
it('returns the expected result', function() {
|
||||
const {
|
||||
examples: [first, second, third, fourth, fifth, sixth],
|
||||
examples: [first, second, third, fourth, fifth],
|
||||
} = DummyService.getDefinition()
|
||||
expect(first).to.deep.equal({
|
||||
title: 'DummyService',
|
||||
@@ -564,8 +556,7 @@ describe('BaseService', function() {
|
||||
documentation: undefined,
|
||||
}
|
||||
expect(third).to.deep.equal(expectedDefinition)
|
||||
expect(fourth).to.deep.equal(expectedDefinition)
|
||||
expect(fifth).to.deep.equal({
|
||||
expect(fourth).to.deep.equal({
|
||||
title: 'DummyService',
|
||||
example: {
|
||||
pattern: '/foo/:world',
|
||||
@@ -580,7 +571,7 @@ describe('BaseService', function() {
|
||||
keywords: ['hello'],
|
||||
documentation: undefined,
|
||||
})
|
||||
expect(sixth).to.deep.equal({
|
||||
expect(fifth).to.deep.equal({
|
||||
title: 'DummyService',
|
||||
example: {
|
||||
pattern: '/foo/:world',
|
||||
|
||||
@@ -46,7 +46,7 @@ module.exports = class David extends LegacyService {
|
||||
title: 'David (path)',
|
||||
pattern: ':user/:repo',
|
||||
namedParams: { user: 'babel', repo: 'babel' },
|
||||
query: { path: 'packages/babel-core' },
|
||||
queryParams: { path: 'packages/babel-core' },
|
||||
staticExample: this.renderStaticExample(),
|
||||
},
|
||||
]
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class GithubFollowers extends LegacyService {
|
||||
{
|
||||
title: 'GitHub followers',
|
||||
previewUrl: 'espadrine',
|
||||
query: { style: 'social', label: 'Follow' },
|
||||
queryParams: { style: 'social', label: 'Follow' },
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class GithubForks extends LegacyService {
|
||||
{
|
||||
title: 'GitHub forks',
|
||||
previewUrl: 'badges/shields',
|
||||
query: { style: 'social', label: 'Fork' },
|
||||
queryParams: { style: 'social', label: 'Fork' },
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = class GithubStars extends LegacyService {
|
||||
{
|
||||
title: 'GitHub stars',
|
||||
previewUrl: 'badges/shields',
|
||||
query: { style: 'social', label: 'Stars' },
|
||||
queryParams: { style: 'social', label: 'Stars' },
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class GithubWatchers extends LegacyService {
|
||||
{
|
||||
title: 'GitHub watchers',
|
||||
previewUrl: 'badges/shields',
|
||||
query: { style: 'social', label: 'Watch' },
|
||||
queryParams: { style: 'social', label: 'Watch' },
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -57,7 +57,7 @@ module.exports = class GitlabPipelineStatus extends BaseSvgScrapingService {
|
||||
title: 'Gitlab pipeline status (self-hosted)',
|
||||
pattern: ':user/:repo',
|
||||
namedParams: { user: 'GNOME', repo: 'pango' },
|
||||
query: { gitlab_url: 'https://gitlab.gnome.org' },
|
||||
queryParams: { gitlab_url: 'https://gitlab.gnome.org' },
|
||||
staticExample: this.render({ status: 'passed' }),
|
||||
},
|
||||
]
|
||||
|
||||
@@ -60,6 +60,8 @@ describe('loadServiceClasses function', function() {
|
||||
})
|
||||
|
||||
it('can collect the service definitions', function() {
|
||||
expect(() => collectDefinitions()).not.to.throw()
|
||||
// When this fails, it will throw AssertionErrors. Wrapping this in an
|
||||
// `expect().not.to.throw()` makes the error output unreadable.
|
||||
collectDefinitions()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -62,7 +62,7 @@ module.exports = class NodeVersion extends NPMBase {
|
||||
title: 'node (scoped with tag, custom registry)',
|
||||
pattern: '@:scope/:packageName/:tag',
|
||||
namedParams: { scope: 'stdlib', packageName: 'stdlib', tag: 'latest' },
|
||||
query: { registry_uri: 'https://registry.npmjs.com' },
|
||||
queryParams: { registry_uri: 'https://registry.npmjs.com' },
|
||||
staticExample: this.renderStaticExample({
|
||||
nodeVersionRange: '>= 6.0.0',
|
||||
tag: 'latest',
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = class NpmLicense extends NpmBase {
|
||||
exampleUrl: 'express',
|
||||
pattern: ':package',
|
||||
staticExample: this.render({ licenses: ['MIT'] }),
|
||||
query: { registry_uri: 'https://registry.npmjs.com' },
|
||||
queryParams: { registry_uri: 'https://registry.npmjs.com' },
|
||||
keywords: ['node'],
|
||||
},
|
||||
]
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = class NpmVersion extends NpmBase {
|
||||
exampleUrl: 'npm/next',
|
||||
pattern: ':package/:tag',
|
||||
staticExample: this.render({ tag: 'latest', version: '7.0.0' }),
|
||||
query: { registry_uri: 'https://registry.npmjs.com' },
|
||||
queryParams: { registry_uri: 'https://registry.npmjs.com' },
|
||||
keywords: ['node'],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -35,9 +35,7 @@ const schema = Joi.object({
|
||||
.default([]),
|
||||
documentation: Joi.string(), // Valid HTML.
|
||||
})
|
||||
.rename('query', 'queryParams', { ignoreUndefined: true })
|
||||
.rename('staticExample', 'staticPreview', { ignoreUndefined: true })
|
||||
.rename('urlPattern', 'pattern', { ignoreUndefined: true })
|
||||
.required()
|
||||
|
||||
function validateExample(example, index, ServiceClass) {
|
||||
|
||||
@@ -23,7 +23,7 @@ class TwitterUrl extends LegacyService {
|
||||
{
|
||||
title: 'Twitter URL',
|
||||
previewUrl: 'http/shields.io',
|
||||
query: { style: 'social' },
|
||||
queryParams: { style: 'social' },
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class TwitterFollow extends LegacyService {
|
||||
{
|
||||
title: 'Twitter Follow',
|
||||
previewUrl: 'espadrine',
|
||||
query: { style: 'social', label: 'Follow' },
|
||||
queryParams: { style: 'social', label: 'Follow' },
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ module.exports = class Website extends LegacyService {
|
||||
return [
|
||||
{
|
||||
previewUrl: 'website-up-down-green-red/https/shields.io',
|
||||
query: { label: 'my-website' },
|
||||
queryParams: { label: 'my-website' },
|
||||
keywords: ['website'],
|
||||
documentation,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user