Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('"false" if the image was not saved', () => {
Image.prototype.save.rejects();
return save_({refPath: '/ref/path'})
.then((res) => assert.isFalse(res));
});
});
beforeEach(() => {
sandbox.stub(Image, 'create').returns(Object.create(Image.prototype));
sandbox.stub(Image, 'compare').resolves(true);
sandbox.stub(Image.prototype, 'getSize');
sandbox.stub(fs, 'readFileSync');
sandbox.stub(fs, 'existsSync').returns(true);
sandbox.stub(temp, 'path');
sandbox.stub(temp, 'attach');
sandbox.stub(RuntimeConfig, 'getInstance').returns({tempOpts: {}});
sandbox.spy(ScreenShooter, 'create');
sandbox.stub(ScreenShooter.prototype, 'capture').resolves(stubImage_());
sandbox.stub(updateRefs, 'handleNoRefImage').resolves();
sandbox.stub(updateRefs, 'handleImageDiff').resolves();
});
beforeEach(() => {
sandbox.stub(fs, 'mkdirsAsync').returns(Promise.resolve());
sandbox.stub(Image.prototype, 'save').returns(Promise.resolve());
});
beforeEach(() => {
sandbox.stub(Image, 'create').returns(Object.create(Image.prototype));
sandbox.stub(Image, 'compare').resolves(true);
sandbox.stub(Image.prototype, 'getSize');
sandbox.stub(fs, 'readFileSync');
sandbox.stub(fs, 'existsSync').returns(true);
sandbox.stub(temp, 'path');
sandbox.stub(temp, 'attach');
sandbox.stub(RuntimeConfig, 'getInstance').returns({tempOpts: {}});
sandbox.spy(ScreenShooter, 'create');
sandbox.stub(ScreenShooter.prototype, 'capture').resolves(stubImage_());
sandbox.stub(updateRefs, 'handleNoRefImage').resolves();
sandbox.stub(updateRefs, 'handleImageDiff').resolves();
beforeEach(() => {
sandbox.stub(fs, 'readFileSync');
sandbox.stub(temp, 'path');
sandbox.stub(utils, 'copyImg').resolves(true);
sandbox.stub(utils, 'saveRef').resolves(true);
sandbox.stub(utils, 'existsRef').resolves(true);
sandbox.stub(Image, 'create').returns(Object.create(Image.prototype));
sandbox.stub(Image, 'compare').resolves(true);
sandbox.stub(Image.prototype, 'save').resolves();
sandbox.stub(Image.prototype, 'getSize');
});
const mkImage = (opts = {}) => {
opts = _.defaults(opts, {size: {width: 100500, height: 500100}});
return {
compare: Image.compare,
save: Image.prototype.save,
getSize: sandbox.stub().returns(opts.size)
};
};
beforeEach(() => {
sandbox.stub(fs, 'readFileSync');
sandbox.stub(temp, 'path');
sandbox.stub(utils, 'copyImg').resolves(true);
sandbox.stub(utils, 'saveRef').resolves(true);
sandbox.stub(utils, 'existsRef').resolves(true);
sandbox.stub(Image, 'create').returns(Object.create(Image.prototype));
sandbox.stub(Image, 'compare').resolves(true);
sandbox.stub(Image.prototype, 'save').resolves();
sandbox.stub(Image.prototype, 'getSize');
});