Skip to content

Commit

Permalink
Eliminate a few coverage misses
Browse files Browse the repository at this point in the history
 - Remove unused `default`s for `switch` statements
 - Fix coverage misses related to un-evaluated default arguments by either:

   - Removing the default if we always set the argument
   - Removing overrides in tests which are the same as the default
   - Ignoring the defaults for coverage purposes
  • Loading branch information
robertknight committed Jul 5, 2023
1 parent 79484cd commit fc5b760
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 17 deletions.
2 changes: 0 additions & 2 deletions src/annotator/adder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,6 @@ export class Adder implements Destroyable {
case 'hide':
this.hide();
break;
default:
break;
}
};

Expand Down
1 change: 0 additions & 1 deletion src/annotator/components/test/AdderToolbar-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ describe('AdderToolbar', () => {
mount(
<AdderToolbar
direction="up"
annotationCount={0}
onCommand={() => {}}
isVisible={true}
{...props}
Expand Down
1 change: 0 additions & 1 deletion src/annotator/components/test/Toolbar-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('Toolbar', () => {
isSidebarOpen={false}
showHighlights={false}
newAnnotationType="note"
useMinimalControls={false}
{...props}
/>
);
Expand Down
1 change: 1 addition & 0 deletions src/annotator/integrations/pdf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class PDFIntegration extends TinyEmitter implements Integration {
*/
constructor(
annotator: Annotator,
/* istanbul ignore next */
options: { reanchoringMaxWait?: number } = {}
) {
super();
Expand Down
14 changes: 7 additions & 7 deletions src/sidebar/components/FilterStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ type FilterStatusMessageProps = {
* A count of items that are visible but do not match the filters (i.e. items
* that have been "forced visible" by the user)
*/
additionalCount?: number;
additionalCount: number;

/** Singular unit of the items being shown, e.g. "result" or "annotation" */
entitySingular?: string;
entitySingular: string;

/** Plural unit of the items being shown */
entityPlural?: string;
entityPlural: string;

/** Currently-applied filter query string, if any */
filterQuery?: string | null;
filterQuery: string | null;

/** Display name for the user currently focused, if any */
focusDisplayName?: string | null;
Expand All @@ -44,9 +44,9 @@ type FilterStatusMessageProps = {
* Render status text describing the currently-applied filters.
*/
function FilterStatusMessage({
additionalCount = 0,
entitySingular = 'annotation',
entityPlural = 'annotations',
additionalCount,
entitySingular,
entityPlural,
filterQuery,
focusDisplayName,
resultCount,
Expand Down
8 changes: 3 additions & 5 deletions src/sidebar/components/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ function handleToolbarCommand(
case 'list':
update(state => toggleBlockStyle(state, '* '));
break;
default:
throw new Error(`Unknown toolbar command "${command}"`);
}
}

Expand Down Expand Up @@ -331,7 +329,7 @@ export type MarkdownEditorProps = {
textStyle?: Record<string, string>;

/** The markdown text to edit */
text?: string;
text: string;

onEditText?: (text: string) => void;
};
Expand All @@ -340,9 +338,9 @@ export type MarkdownEditorProps = {
* Viewer/editor for the body of an annotation in markdown format.
*/
export default function MarkdownEditor({
label = '',
label,
onEditText = () => {},
text = '',
text,
textStyle = {},
}: MarkdownEditorProps) {
// Whether the preview mode is currently active.
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/helpers/build-thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function hasPathToRoot(
function setParent(
threads: Record<string, Thread>,
id: string,
parents: string[] = []
parents: string[]
) {
if (threads[id].parent || !parents.length) {
// Parent already assigned, do not try to change it.
Expand Down
1 change: 1 addition & 0 deletions src/sidebar/service-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function withServices<
// Debugging check to make sure the store is used correctly.
if (process.env.NODE_ENV !== 'production') {
if (service === 'store') {
/* istanbul ignore next - Ignore debug code */
throw new Error(
'Do not use `withServices` to inject the `store` service. Use the `useStore` hook instead'
);
Expand Down
1 change: 1 addition & 0 deletions src/sidebar/util/immutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function deepFreeze<T extends object>(object: T) {
*/
export function immutable<T extends object>(object: T) {
if (process.env.NODE_ENV === 'production') {
/* istanbul ignore next */
return object;
} else {
return deepFreeze(object);
Expand Down
1 change: 1 addition & 0 deletions src/sidebar/util/postmessage-json-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function call<T>(
method: string,
/* istanbul ignore next */
params: unknown[] = [],
/* istanbul ignore next */
timeout = 2000,
/* istanbul ignore next */
window_: Window = window
Expand Down

0 comments on commit fc5b760

Please sign in to comment.