mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-31 18:07:00 +02:00
test: fix some type errors in test files (#7486)
This commit is contained in:
parent
624735bd92
commit
e2e40b8f5f
50 changed files with 319 additions and 182 deletions
|
@ -8,6 +8,7 @@
|
|||
import React from 'react';
|
||||
import {EnumChangefreq} from 'sitemap';
|
||||
import createSitemap from '../createSitemap';
|
||||
import type {PluginOptions} from '../options';
|
||||
import type {DocusaurusConfig} from '@docusaurus/types';
|
||||
|
||||
describe('createSitemap', () => {
|
||||
|
@ -31,7 +32,8 @@ describe('createSitemap', () => {
|
|||
|
||||
it('empty site', () =>
|
||||
expect(async () => {
|
||||
await createSitemap({} as DocusaurusConfig, [], {}, {});
|
||||
// @ts-expect-error: test
|
||||
await createSitemap({}, [], {}, {} as PluginOptions);
|
||||
}).rejects.toThrow(
|
||||
'URL in docusaurus.config.js cannot be empty/undefined.',
|
||||
));
|
||||
|
@ -148,6 +150,7 @@ describe('createSitemap', () => {
|
|||
{
|
||||
'/noindex': {
|
||||
meta: {
|
||||
// @ts-expect-error: bad lib def
|
||||
toComponent: () => [
|
||||
React.createElement('meta', {name: 'robots', content: 'noindex'}),
|
||||
],
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('validateOptions', () => {
|
|||
});
|
||||
|
||||
it('accepts correctly defined user options', () => {
|
||||
const userOptions = {
|
||||
const userOptions: Options = {
|
||||
changefreq: 'yearly',
|
||||
priority: 0.9,
|
||||
ignorePatterns: ['/search/**'],
|
||||
|
@ -52,9 +52,11 @@ describe('validateOptions', () => {
|
|||
|
||||
it('rejects bad ignorePatterns inputs', () => {
|
||||
expect(() =>
|
||||
// @ts-expect-error: test
|
||||
testValidate({ignorePatterns: '/search'}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`""ignorePatterns" must be an array"`);
|
||||
expect(() =>
|
||||
// @ts-expect-error: test
|
||||
testValidate({ignorePatterns: [/^\/search/]}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`""ignorePatterns[0]" must be a string"`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue