Skip to content

Commit

Permalink
fix: add types for stablePatchmarks (#74)
Browse files Browse the repository at this point in the history
* fix: add types for stablePatchmarks

* fix flow
  • Loading branch information
thymikee committed Mar 16, 2019
1 parent 0daad5a commit 71b595a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type DiffOptions = {
expand?: boolean
colors?: boolean
contextLines?: number
stablePatchmarks?: boolean
aAnnotation?: string
bAnnotation?: string
}
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ const prettyFormat = require('pretty-format');
const { ReactElement } = prettyFormat.plugins;
const reactElement = Symbol.for('react.element');

type Options = {
type Options = {|
expand?: boolean,
colors?: boolean,
contextLines?: number,
stablePatchmarks?: boolean,
aAnnotation?: string,
bAnnotation?: string,
};
|};

const defaultOptions = {
expand: false,
Expand All @@ -30,7 +31,7 @@ const SNAPSHOT_TITLE = 'Snapshot Diff:\n';

const snapshotDiff = (valueA: any, valueB: any, options?: Options): string => {
let difference;
const mergedOptions = Object.assign({}, defaultOptions, options);
const mergedOptions = { ...defaultOptions, ...options };

if (isReactComponent(valueA) && isReactComponent(valueB)) {
difference = diffReactComponents(valueA, valueB, mergedOptions);
Expand Down

0 comments on commit 71b595a

Please sign in to comment.