fix tests

This commit is contained in:
ozakione 2024-04-17 23:52:47 +02:00
parent 2855df5776
commit 38a71a6f07
3 changed files with 13 additions and 10 deletions

View file

@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {fromPartial} from '@total-typescript/shoehorn';
import {normalizePluginOptions} from '@docusaurus/utils-validation';
import {validateOptions, DEFAULT_OPTIONS} from '../options';
import type {Options} from '@docusaurus/plugin-content-showcase';
@ -101,7 +102,7 @@ describe('normalizeShowcasePluginOptions', () => {
},
},
};
expect(testValidate(userOptions)).toEqual({
expect(testValidate(fromPartial(userOptions))).toEqual({
...defaultOptions,
...userOptions,
});

View file

@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {fromPartial} from '@total-typescript/shoehorn';
import {getTagsList} from '../tags';
const tags = {
@ -32,24 +33,24 @@ const invalidTags = {
describe('showcase tags', () => {
it('get tag list', async () => {
const tagList = await getTagsList({
configTags: tags,
const {tagKeys} = await getTagsList({
configTags: fromPartial(tags),
configPath: '',
});
expect(tagList).toEqual(Object.keys(tags));
expect(tagKeys).toEqual(Object.keys(tags));
});
it('get tag list from file', async () => {
const tagList = await getTagsList({
const {tagKeys} = await getTagsList({
configTags: './__fixtures__/tags.yml',
configPath: __dirname,
});
expect(tagList).toEqual(Object.keys(tags));
expect(tagKeys).toEqual(Object.keys(tags));
});
it('error get tag list', async () => {
const tagList = getTagsList({
configTags: invalidTags,
configTags: fromPartial(invalidTags),
configPath: '',
});

View file

@ -31,11 +31,11 @@ const tags = {
};
async function prepareSchema() {
const tagList = await getTagsList({
configTags: tags,
const {tagKeys} = await getTagsList({
configTags: fromPartial(tags),
configPath: '',
});
return createShowcaseItemSchema(tagList);
return createShowcaseItemSchema(tagKeys);
}
describe('showcase item schema', () => {
@ -57,6 +57,7 @@ describe('showcase item schema', () => {
description: 'description',
preview: 'preview',
source: 'source',
// @ts-expect-error: invalid tag
tags: ['invalid'],
website: 'website',
};