fix: NativeImage.getScaleFactors returns correct scales (#25832)

* fix: NativeImage.getScaleFactors returns correct scales

* fix tests
This commit is contained in:
Jeremy Rose 2020-10-12 18:59:18 -07:00 committed by GitHub
parent 9cd882f1fa
commit cbe751d349
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 12 deletions

View file

@ -539,23 +539,32 @@ describe('nativeImage module', () => {
buffer: nativeImage.createFromPath(imageDataOne.path).toPNG()
});
expect(image.getScaleFactors()).to.deep.equal([1]);
const imageDataTwo = getImage({ width: 2, height: 2 });
image.addRepresentation({
scaleFactor: 2.0,
buffer: nativeImage.createFromPath(imageDataTwo.path).toPNG()
});
expect(image.getScaleFactors()).to.deep.equal([1, 2]);
const imageDataThree = getImage({ width: 3, height: 3 });
image.addRepresentation({
scaleFactor: 3.0,
buffer: nativeImage.createFromPath(imageDataThree.path).toPNG()
});
expect(image.getScaleFactors()).to.deep.equal([1, 2, 3]);
image.addRepresentation({
scaleFactor: 4.0,
buffer: 'invalid'
});
// this one failed, so it shouldn't show up in the scale factors
expect(image.getScaleFactors()).to.deep.equal([1, 2, 3]);
expect(image.isEmpty()).to.be.false();
expect(image.getSize()).to.deep.equal({ width: 1, height: 1 });