Skip to content

Commit

Permalink
feat(plugintestbed): forbid warn/error logger in mock plugin by default
Browse files Browse the repository at this point in the history
  • Loading branch information
GerkinDev committed Jul 19, 2022
1 parent d069278 commit 0081e0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
@@ -1,6 +1,7 @@
import { resolve } from 'path';

import { DeclarationReflection, ReflectionKind } from 'typedoc';
import { noop } from 'lodash';
import { DeclarationReflection, ReflectionKind, RepositoryType } from 'typedoc';

import { MockPlugin, createMockProjectWithPackage, mockPlugin, restoreFs, setVirtualFs, setupMockMarkdownReplacer, setupMockPageMemo } from '#plugintestbed';

Expand Down Expand Up @@ -98,6 +99,7 @@ describe( 'Behavior', () => {
it( 'should not alter content if region does not exists', () => {
readCodeSampleMock.mockReturnValue( new Map( [[ DEFAULT_BLOCK_NAME, { code: FILE_CONTENT, ...defaultBlock } ]] ) );
const content = '{@codeblock foo/baz.txt#nope}';
plugin.logger.error.mockImplementation( noop );
expect( markdownReplacerTestbed.runMarkdownReplace( content ) ).toEqual( content );
} );
it( 'should throw if invalid mode', () => {
Expand Down
@@ -1,6 +1,6 @@
import { resolve } from 'path';

import { isString, omit } from 'lodash';
import { isString, noop, omit } from 'lodash';
import { Class } from 'type-fest';
import { Comment, DeclarationReflection, LogLevel, ProjectReflection, Reflection, ReflectionKind, SourceReference } from 'typedoc';

Expand Down Expand Up @@ -77,6 +77,7 @@ describe( 'Project', () => {
] );
} );
it( 'should strip empty menu', () => {
plugin.logger.warn.mockImplementation( noop );
const out = pageTreeBuilder.buildPagesTree( project, opts( [ { title: 'Foo' } ] ) );
expect( out.childrenNodes ).toEqual( [] );
} );
Expand Down
4 changes: 2 additions & 2 deletions packages/plugintestbed/src/mock-plugin.ts
Expand Up @@ -9,8 +9,8 @@ export type MockPlugin<T extends ABasePlugin> = jest.MockedObjectDeep<T>
export const mockPlugin = <T extends ABasePlugin>( props: Partial<MockPlugin<T>> = {} ): MockPlugin<T> => {
const mockLogger = {
makeChildLogger: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
error: jest.fn().mockImplementation( v => fail( `Unexpected error log: ${typeof v === 'function' ? v() : v}` ) ),
warn: jest.fn().mockImplementation( v => fail( `Unexpected warn log: ${typeof v === 'function' ? v() : v}` ) ),
log: jest.fn(),
verbose: jest.fn(),
info: jest.fn(),
Expand Down

0 comments on commit 0081e0d

Please sign in to comment.