Skip to content

Commit

Permalink
fix(prepareOpts): TypeError when opts is undefined (#66)
Browse files Browse the repository at this point in the history
* fix(prepareOpts): TypeError when opts is undefined
  • Loading branch information
Vorobeyko authored May 8, 2020
1 parent 20f2512 commit c6ea6c2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ interface Color {
declare function looksSame(
image1: string | Buffer | BoundedImage,
image2: string | Buffer | BoundedImage,
options: LooksSameOptions,
options: LooksSameOptions | {},
callback: LooksSameCallback
): void;
/**
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const getToleranceFromOpts = (opts) => {
};

const prepareOpts = (opts) => {
opts = opts || {};
opts.tolerance = getToleranceFromOpts(opts);

return _.defaults(opts, {
Expand Down
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ describe('looksSame', () => {
}).to.throw(TypeError);
});

it('should work when opts is undefined', () => {
expect(() => {
looksSame(srcPath('ref.png'), srcPath('same.png'), undefined, () => {});
}).not.to.throw(TypeError);
});

it('should format images', (done) => {
sandbox.spy(utils, 'formatImages');

Expand Down

0 comments on commit c6ea6c2

Please sign in to comment.