chore: update to standard 12
This commit is contained in:
		
					parent
					
						
							
								9e85bdb02c
							
						
					
				
			
			
				commit
				
					
						558fff69e7
					
				
			
		
					 198 changed files with 4455 additions and 2940 deletions
				
			
		|  | @ -2,10 +2,10 @@ | |||
| 
 | ||||
| const chai = require('chai') | ||||
| const dirtyChai = require('dirty-chai') | ||||
| const {nativeImage} = require('electron') | ||||
| const { nativeImage } = require('electron') | ||||
| const path = require('path') | ||||
| 
 | ||||
| const {expect} = chai | ||||
| const { expect } = chai | ||||
| chai.use(dirtyChai) | ||||
| 
 | ||||
| describe('nativeImage module', () => { | ||||
|  | @ -58,7 +58,7 @@ describe('nativeImage module', () => { | |||
|    */ | ||||
|   const getImagePathFromFilename = (filename) => { | ||||
|     return (filename === null) ? null | ||||
|         : path.join(__dirname, 'fixtures', 'assets', filename) | ||||
|       : path.join(__dirname, 'fixtures', 'assets', filename) | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|  | @ -72,7 +72,7 @@ describe('nativeImage module', () => { | |||
|     } | ||||
| 
 | ||||
|     return Object.entries(filters) | ||||
|         .every(([key, value]) => image[key] === value) | ||||
|       .every(([key, value]) => image[key] === value) | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|  | @ -81,11 +81,11 @@ describe('nativeImage module', () => { | |||
|    */ | ||||
|   const getImages = (filters) => { | ||||
|     const matchingImages = images | ||||
|         .filter(i => imageMatchesTheFilters(i, filters)) | ||||
|       .filter(i => imageMatchesTheFilters(i, filters)) | ||||
| 
 | ||||
|     // Add `.path` property to every image.
 | ||||
|     matchingImages | ||||
|         .forEach(i => { i.path = getImagePathFromFilename(i.filename) }) | ||||
|       .forEach(i => { i.path = getImagePathFromFilename(i.filename) }) | ||||
| 
 | ||||
|     return matchingImages | ||||
|   } | ||||
|  | @ -111,15 +111,15 @@ describe('nativeImage module', () => { | |||
|       expect(empty.isEmpty()) | ||||
|       expect(empty.getAspectRatio()).to.equal(1) | ||||
|       expect(empty.toDataURL()).to.equal('data:image/png;base64,') | ||||
|       expect(empty.toDataURL({scaleFactor: 2.0})).to.equal('data:image/png;base64,') | ||||
|       expect(empty.getSize()).to.deep.equal({width: 0, height: 0}) | ||||
|       expect(empty.toDataURL({ scaleFactor: 2.0 })).to.equal('data:image/png;base64,') | ||||
|       expect(empty.getSize()).to.deep.equal({ width: 0, height: 0 }) | ||||
|       expect(empty.getBitmap()).to.be.empty() | ||||
|       expect(empty.getBitmap({scaleFactor: 2.0})).to.be.empty() | ||||
|       expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty() | ||||
|       expect(empty.toBitmap()).to.be.empty() | ||||
|       expect(empty.toBitmap({scaleFactor: 2.0})).to.be.empty() | ||||
|       expect(empty.toBitmap({ scaleFactor: 2.0 })).to.be.empty() | ||||
|       expect(empty.toJPEG(100)).to.be.empty() | ||||
|       expect(empty.toPNG()).to.be.empty() | ||||
|       expect(empty.toPNG({scaleFactor: 2.0})).to.be.empty() | ||||
|       expect(empty.toPNG({ scaleFactor: 2.0 })).to.be.empty() | ||||
| 
 | ||||
|       if (process.platform === 'darwin') { | ||||
|         expect(empty.getNativeHandle()).to.be.empty() | ||||
|  | @ -136,34 +136,34 @@ describe('nativeImage module', () => { | |||
|       const imageA = nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', 'logo.png')) | ||||
| 
 | ||||
|       const imageB = nativeImage.createFromBuffer(imageA.toPNG()) | ||||
|       expect(imageB.getSize()).to.deep.equal({width: 538, height: 190}) | ||||
|       expect(imageB.getSize()).to.deep.equal({ width: 538, height: 190 }) | ||||
|       expect(imageA.toBitmap().equals(imageB.toBitmap())).to.be.true() | ||||
| 
 | ||||
|       const imageC = nativeImage.createFromBuffer(imageA.toJPEG(100)) | ||||
|       expect(imageC.getSize()).to.deep.equal({width: 538, height: 190}) | ||||
|       expect(imageC.getSize()).to.deep.equal({ width: 538, height: 190 }) | ||||
| 
 | ||||
|       const imageD = nativeImage.createFromBuffer(imageA.toBitmap(), | ||||
|         {width: 538, height: 190}) | ||||
|       expect(imageD.getSize()).to.deep.equal({width: 538, height: 190}) | ||||
|         { width: 538, height: 190 }) | ||||
|       expect(imageD.getSize()).to.deep.equal({ width: 538, height: 190 }) | ||||
| 
 | ||||
|       const imageE = nativeImage.createFromBuffer(imageA.toBitmap(), | ||||
|         {width: 100, height: 200}) | ||||
|       expect(imageE.getSize()).to.deep.equal({width: 100, height: 200}) | ||||
|         { width: 100, height: 200 }) | ||||
|       expect(imageE.getSize()).to.deep.equal({ width: 100, height: 200 }) | ||||
| 
 | ||||
|       const imageF = nativeImage.createFromBuffer(imageA.toBitmap()) | ||||
|       expect(imageF.isEmpty()) | ||||
| 
 | ||||
|       const imageG = nativeImage.createFromBuffer(imageA.toPNG(), | ||||
|         {width: 100, height: 200}) | ||||
|       expect(imageG.getSize()).to.deep.equal({width: 538, height: 190}) | ||||
|         { width: 100, height: 200 }) | ||||
|       expect(imageG.getSize()).to.deep.equal({ width: 538, height: 190 }) | ||||
| 
 | ||||
|       const imageH = nativeImage.createFromBuffer(imageA.toJPEG(100), | ||||
|         {width: 100, height: 200}) | ||||
|       expect(imageH.getSize()).to.deep.equal({width: 538, height: 190}) | ||||
|         { width: 100, height: 200 }) | ||||
|       expect(imageH.getSize()).to.deep.equal({ width: 538, height: 190 }) | ||||
| 
 | ||||
|       const imageI = nativeImage.createFromBuffer(imageA.toBitmap(), | ||||
|         {width: 538, height: 190, scaleFactor: 2.0}) | ||||
|       expect(imageI.getSize()).to.deep.equal({width: 269, height: 95}) | ||||
|         { width: 538, height: 190, scaleFactor: 2.0 }) | ||||
|       expect(imageI.getSize()).to.deep.equal({ width: 269, height: 95 }) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -173,7 +173,7 @@ describe('nativeImage module', () => { | |||
|     }) | ||||
| 
 | ||||
|     it('returns an image created from the given string', () => { | ||||
|       const imagesData = getImages({hasDataUrl: true}) | ||||
|       const imagesData = getImages({ hasDataUrl: true }) | ||||
|       for (const imageData of imagesData) { | ||||
|         const imageFromPath = nativeImage.createFromPath(imageData.path) | ||||
|         const imageFromDataUrl = nativeImage.createFromDataURL(imageData.dataUrl) | ||||
|  | @ -181,7 +181,7 @@ describe('nativeImage module', () => { | |||
|         expect(imageFromDataUrl.isEmpty()) | ||||
|         expect(imageFromDataUrl.getSize()).to.deep.equal(imageFromPath.getSize()) | ||||
|         expect(imageFromDataUrl.toBitmap()).to.satisfy( | ||||
|             bitmap => imageFromPath.toBitmap().equals(bitmap)) | ||||
|           bitmap => imageFromPath.toBitmap().equals(bitmap)) | ||||
|         expect(imageFromDataUrl.toDataURL()).to.equal(imageFromPath.toDataURL()) | ||||
|       } | ||||
|     }) | ||||
|  | @ -189,19 +189,19 @@ describe('nativeImage module', () => { | |||
| 
 | ||||
|   describe('toDataURL()', () => { | ||||
|     it('returns a PNG data URL', () => { | ||||
|       const imagesData = getImages({hasDataUrl: true}) | ||||
|       const imagesData = getImages({ hasDataUrl: true }) | ||||
|       for (const imageData of imagesData) { | ||||
|         const imageFromPath = nativeImage.createFromPath(imageData.path) | ||||
| 
 | ||||
|         const scaleFactors = [1.0, 2.0] | ||||
|         for (const scaleFactor of scaleFactors) { | ||||
|           expect(imageFromPath.toDataURL({scaleFactor})).to.equal(imageData.dataUrl) | ||||
|           expect(imageFromPath.toDataURL({ scaleFactor })).to.equal(imageData.dataUrl) | ||||
|         } | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|     it('returns a data URL at 1x scale factor by default', () => { | ||||
|       const imageData = getImage({filename: 'logo.png'}) | ||||
|       const imageData = getImage({ filename: 'logo.png' }) | ||||
|       const image = nativeImage.createFromPath(imageData.path) | ||||
| 
 | ||||
|       const imageOne = nativeImage.createFromBuffer(image.toPNG(), { | ||||
|  | @ -210,33 +210,33 @@ describe('nativeImage module', () => { | |||
|         scaleFactor: 2.0 | ||||
|       }) | ||||
|       expect(imageOne.getSize()).to.deep.equal( | ||||
|           {width: imageData.width / 2, height: imageData.height / 2}) | ||||
|         { width: imageData.width / 2, height: imageData.height / 2 }) | ||||
| 
 | ||||
|       const imageTwo = nativeImage.createFromDataURL(imageOne.toDataURL()) | ||||
|       expect(imageTwo.getSize()).to.deep.equal( | ||||
|           {width: imageData.width, height: imageData.height}) | ||||
|         { width: imageData.width, height: imageData.height }) | ||||
| 
 | ||||
|       expect(imageOne.toBitmap().equals(imageTwo.toBitmap())).to.be.true() | ||||
|     }) | ||||
| 
 | ||||
|     it('supports a scale factor', () => { | ||||
|       const imageData = getImage({filename: 'logo.png'}) | ||||
|       const imageData = getImage({ filename: 'logo.png' }) | ||||
|       const image = nativeImage.createFromPath(imageData.path) | ||||
|       const expectedSize = {width: imageData.width, height: imageData.height} | ||||
|       const expectedSize = { width: imageData.width, height: imageData.height } | ||||
| 
 | ||||
|       const imageFromDataUrlOne = nativeImage.createFromDataURL( | ||||
|           image.toDataURL({scaleFactor: 1.0})) | ||||
|         image.toDataURL({ scaleFactor: 1.0 })) | ||||
|       expect(imageFromDataUrlOne.getSize()).to.deep.equal(expectedSize) | ||||
| 
 | ||||
|       const imageFromDataUrlTwo = nativeImage.createFromDataURL( | ||||
|           image.toDataURL({scaleFactor: 2.0})) | ||||
|         image.toDataURL({ scaleFactor: 2.0 })) | ||||
|       expect(imageFromDataUrlTwo.getSize()).to.deep.equal(expectedSize) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|   describe('toPNG()', () => { | ||||
|     it('returns a buffer at 1x scale factor by default', () => { | ||||
|       const imageData = getImage({filename: 'logo.png'}) | ||||
|       const imageData = getImage({ filename: 'logo.png' }) | ||||
|       const imageA = nativeImage.createFromPath(imageData.path) | ||||
| 
 | ||||
|       const imageB = nativeImage.createFromBuffer(imageA.toPNG(), { | ||||
|  | @ -245,28 +245,28 @@ describe('nativeImage module', () => { | |||
|         scaleFactor: 2.0 | ||||
|       }) | ||||
|       expect(imageB.getSize()).to.deep.equal( | ||||
|           {width: imageData.width / 2, height: imageData.height / 2}) | ||||
|         { width: imageData.width / 2, height: imageData.height / 2 }) | ||||
| 
 | ||||
|       const imageC = nativeImage.createFromBuffer(imageB.toPNG()) | ||||
|       expect(imageC.getSize()).to.deep.equal( | ||||
|           {width: imageData.width, height: imageData.height}) | ||||
|         { width: imageData.width, height: imageData.height }) | ||||
| 
 | ||||
|       expect(imageB.toBitmap().equals(imageC.toBitmap())).to.be.true() | ||||
|     }) | ||||
| 
 | ||||
|     it('supports a scale factor', () => { | ||||
|       const imageData = getImage({filename: 'logo.png'}) | ||||
|       const imageData = getImage({ filename: 'logo.png' }) | ||||
|       const image = nativeImage.createFromPath(imageData.path) | ||||
| 
 | ||||
|       const imageFromBufferOne = nativeImage.createFromBuffer( | ||||
|           image.toPNG({scaleFactor: 1.0})) | ||||
|         image.toPNG({ scaleFactor: 1.0 })) | ||||
|       expect(imageFromBufferOne.getSize()).to.deep.equal( | ||||
|           {width: imageData.width, height: imageData.height}) | ||||
|         { width: imageData.width, height: imageData.height }) | ||||
| 
 | ||||
|       const imageFromBufferTwo = nativeImage.createFromBuffer( | ||||
|           image.toPNG({scaleFactor: 2.0}), {scaleFactor: 2.0}) | ||||
|         image.toPNG({ scaleFactor: 2.0 }), { scaleFactor: 2.0 }) | ||||
|       expect(imageFromBufferTwo.getSize()).to.deep.equal( | ||||
|           {width: imageData.width / 2, height: imageData.height / 2}) | ||||
|         { width: imageData.width / 2, height: imageData.height / 2 }) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -283,21 +283,21 @@ describe('nativeImage module', () => { | |||
|       const imagePath = path.relative('.', path.join(__dirname, 'fixtures', 'assets', 'logo.png')) | ||||
|       const image = nativeImage.createFromPath(imagePath) | ||||
|       expect(image.isEmpty()).to.be.false() | ||||
|       expect(image.getSize()).to.deep.equal({width: 538, height: 190}) | ||||
|       expect(image.getSize()).to.deep.equal({ width: 538, height: 190 }) | ||||
|     }) | ||||
| 
 | ||||
|     it('loads images from paths with `.` segments', () => { | ||||
|       const imagePath = `${path.join(__dirname, 'fixtures')}${path.sep}.${path.sep}${path.join('assets', 'logo.png')}` | ||||
|       const image = nativeImage.createFromPath(imagePath) | ||||
|       expect(image.isEmpty()).to.be.false() | ||||
|       expect(image.getSize()).to.deep.equal({width: 538, height: 190}) | ||||
|       expect(image.getSize()).to.deep.equal({ width: 538, height: 190 }) | ||||
|     }) | ||||
| 
 | ||||
|     it('loads images from paths with `..` segments', () => { | ||||
|       const imagePath = `${path.join(__dirname, 'fixtures', 'api')}${path.sep}..${path.sep}${path.join('assets', 'logo.png')}` | ||||
|       const image = nativeImage.createFromPath(imagePath) | ||||
|       expect(image.isEmpty()).to.be.false() | ||||
|       expect(image.getSize()).to.deep.equal({width: 538, height: 190}) | ||||
|       expect(image.getSize()).to.deep.equal({ width: 538, height: 190 }) | ||||
|     }) | ||||
| 
 | ||||
|     it('Gets an NSImage pointer on macOS', function () { | ||||
|  | @ -328,7 +328,7 @@ describe('nativeImage module', () => { | |||
|       const imagePath = path.join(__dirname, 'fixtures', 'assets', 'icon.ico') | ||||
|       const image = nativeImage.createFromPath(imagePath) | ||||
|       expect(image.isEmpty()).to.be.false() | ||||
|       expect(image.getSize()).to.deep.equal({width: 256, height: 256}) | ||||
|       expect(image.getSize()).to.deep.equal({ width: 256, height: 256 }) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -376,15 +376,15 @@ describe('nativeImage module', () => { | |||
|     it('returns a resized image', () => { | ||||
|       const image = nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', 'logo.png')) | ||||
|       for (const [resizeTo, expectedSize] of new Map([ | ||||
|         [{}, {width: 538, height: 190}], | ||||
|         [{width: 269}, {width: 269, height: 95}], | ||||
|         [{width: 600}, {width: 600, height: 212}], | ||||
|         [{height: 95}, {width: 269, height: 95}], | ||||
|         [{height: 200}, {width: 566, height: 200}], | ||||
|         [{width: 80, height: 65}, {width: 80, height: 65}], | ||||
|         [{width: 600, height: 200}, {width: 600, height: 200}], | ||||
|         [{width: 0, height: 0}, {width: 0, height: 0}], | ||||
|         [{width: -1, height: -1}, {width: 0, height: 0}] | ||||
|         [{}, { width: 538, height: 190 }], | ||||
|         [{ width: 269 }, { width: 269, height: 95 }], | ||||
|         [{ width: 600 }, { width: 600, height: 212 }], | ||||
|         [{ height: 95 }, { width: 269, height: 95 }], | ||||
|         [{ height: 200 }, { width: 566, height: 200 }], | ||||
|         [{ width: 80, height: 65 }, { width: 80, height: 65 }], | ||||
|         [{ width: 600, height: 200 }, { width: 600, height: 200 }], | ||||
|         [{ width: 0, height: 0 }, { width: 0, height: 0 }], | ||||
|         [{ width: -1, height: -1 }, { width: 0, height: 0 }] | ||||
|       ])) { | ||||
|         const actualSize = image.resize(resizeTo).getSize() | ||||
|         expect(actualSize).to.deep.equal(expectedSize) | ||||
|  | @ -392,15 +392,15 @@ describe('nativeImage module', () => { | |||
|     }) | ||||
| 
 | ||||
|     it('returns an empty image when called on an empty image', () => { | ||||
|       expect(nativeImage.createEmpty().resize({width: 1, height: 1}).isEmpty()) | ||||
|       expect(nativeImage.createEmpty().resize({width: 0, height: 0}).isEmpty()) | ||||
|       expect(nativeImage.createEmpty().resize({ width: 1, height: 1 }).isEmpty()) | ||||
|       expect(nativeImage.createEmpty().resize({ width: 0, height: 0 }).isEmpty()) | ||||
|     }) | ||||
| 
 | ||||
|     it('supports a quality option', () => { | ||||
|       const image = nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', 'logo.png')) | ||||
|       const good = image.resize({width: 100, height: 100, quality: 'good'}) | ||||
|       const better = image.resize({width: 100, height: 100, quality: 'better'}) | ||||
|       const best = image.resize({width: 100, height: 100, quality: 'best'}) | ||||
|       const good = image.resize({ width: 100, height: 100, quality: 'good' }) | ||||
|       const better = image.resize({ width: 100, height: 100, quality: 'better' }) | ||||
|       const best = image.resize({ width: 100, height: 100, quality: 'best' }) | ||||
| 
 | ||||
|       expect(good.toPNG()).to.have.lengthOf.at.most(better.toPNG().length) | ||||
|       expect(better.toPNG()).to.have.lengthOf.below(best.toPNG().length) | ||||
|  | @ -409,24 +409,24 @@ describe('nativeImage module', () => { | |||
| 
 | ||||
|   describe('crop(bounds)', () => { | ||||
|     it('returns an empty image when called on an empty image', () => { | ||||
|       expect(nativeImage.createEmpty().crop({width: 1, height: 2, x: 0, y: 0}).isEmpty()) | ||||
|       expect(nativeImage.createEmpty().crop({width: 0, height: 0, x: 0, y: 0}).isEmpty()) | ||||
|       expect(nativeImage.createEmpty().crop({ width: 1, height: 2, x: 0, y: 0 }).isEmpty()) | ||||
|       expect(nativeImage.createEmpty().crop({ width: 0, height: 0, x: 0, y: 0 }).isEmpty()) | ||||
|     }) | ||||
| 
 | ||||
|     it('returns an empty image when the bounds are invalid', () => { | ||||
|       const image = nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', 'logo.png')) | ||||
|       expect(image.crop({width: 0, height: 0, x: 0, y: 0}).isEmpty()) | ||||
|       expect(image.crop({width: -1, height: 10, x: 0, y: 0}).isEmpty()) | ||||
|       expect(image.crop({width: 10, height: -35, x: 0, y: 0}).isEmpty()) | ||||
|       expect(image.crop({width: 100, height: 100, x: 1000, y: 1000}).isEmpty()) | ||||
|       expect(image.crop({ width: 0, height: 0, x: 0, y: 0 }).isEmpty()) | ||||
|       expect(image.crop({ width: -1, height: 10, x: 0, y: 0 }).isEmpty()) | ||||
|       expect(image.crop({ width: 10, height: -35, x: 0, y: 0 }).isEmpty()) | ||||
|       expect(image.crop({ width: 100, height: 100, x: 1000, y: 1000 }).isEmpty()) | ||||
|     }) | ||||
| 
 | ||||
|     it('returns a cropped image', () => { | ||||
|       const image = nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', 'logo.png')) | ||||
|       const cropA = image.crop({width: 25, height: 64, x: 0, y: 0}) | ||||
|       const cropB = image.crop({width: 25, height: 64, x: 30, y: 40}) | ||||
|       expect(cropA.getSize()).to.deep.equal({width: 25, height: 64}) | ||||
|       expect(cropB.getSize()).to.deep.equal({width: 25, height: 64}) | ||||
|       const cropA = image.crop({ width: 25, height: 64, x: 0, y: 0 }) | ||||
|       const cropB = image.crop({ width: 25, height: 64, x: 30, y: 40 }) | ||||
|       expect(cropA.getSize()).to.deep.equal({ width: 25, height: 64 }) | ||||
|       expect(cropB.getSize()).to.deep.equal({ width: 25, height: 64 }) | ||||
|       expect(cropA.toPNG().equals(cropB.toPNG())).to.be.false() | ||||
|     }) | ||||
|   }) | ||||
|  | @ -437,7 +437,7 @@ describe('nativeImage module', () => { | |||
|     }) | ||||
| 
 | ||||
|     it('returns an aspect ratio of an image', () => { | ||||
|       const imageData = getImage({filename: 'logo.png'}) | ||||
|       const imageData = getImage({ filename: 'logo.png' }) | ||||
|       // imageData.width / imageData.height = 2.831578947368421
 | ||||
|       const expectedAspectRatio = 2.8315789699554443 | ||||
| 
 | ||||
|  | @ -450,19 +450,19 @@ describe('nativeImage module', () => { | |||
|     it('supports adding a buffer representation for a scale factor', () => { | ||||
|       const image = nativeImage.createEmpty() | ||||
| 
 | ||||
|       const imageDataOne = getImage({width: 1, height: 1}) | ||||
|       const imageDataOne = getImage({ width: 1, height: 1 }) | ||||
|       image.addRepresentation({ | ||||
|         scaleFactor: 1.0, | ||||
|         buffer: nativeImage.createFromPath(imageDataOne.path).toPNG() | ||||
|       }) | ||||
| 
 | ||||
|       const imageDataTwo = getImage({width: 2, height: 2}) | ||||
|       const imageDataTwo = getImage({ width: 2, height: 2 }) | ||||
|       image.addRepresentation({ | ||||
|         scaleFactor: 2.0, | ||||
|         buffer: nativeImage.createFromPath(imageDataTwo.path).toPNG() | ||||
|       }) | ||||
| 
 | ||||
|       const imageDataThree = getImage({width: 3, height: 3}) | ||||
|       const imageDataThree = getImage({ width: 3, height: 3 }) | ||||
|       image.addRepresentation({ | ||||
|         scaleFactor: 3.0, | ||||
|         buffer: nativeImage.createFromPath(imageDataThree.path).toPNG() | ||||
|  | @ -474,30 +474,30 @@ describe('nativeImage module', () => { | |||
|       }) | ||||
| 
 | ||||
|       expect(image.isEmpty()).to.be.false() | ||||
|       expect(image.getSize()).to.deep.equal({width: 1, height: 1}) | ||||
|       expect(image.getSize()).to.deep.equal({ width: 1, height: 1 }) | ||||
| 
 | ||||
|       expect(image.toDataURL({scaleFactor: 1.0})).to.equal(imageDataOne.dataUrl) | ||||
|       expect(image.toDataURL({scaleFactor: 2.0})).to.equal(imageDataTwo.dataUrl) | ||||
|       expect(image.toDataURL({scaleFactor: 3.0})).to.equal(imageDataThree.dataUrl) | ||||
|       expect(image.toDataURL({scaleFactor: 4.0})).to.equal(imageDataThree.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 1.0 })).to.equal(imageDataOne.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 2.0 })).to.equal(imageDataTwo.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 3.0 })).to.equal(imageDataThree.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 4.0 })).to.equal(imageDataThree.dataUrl) | ||||
|     }) | ||||
| 
 | ||||
|     it('supports adding a data URL representation for a scale factor', () => { | ||||
|       const image = nativeImage.createEmpty() | ||||
| 
 | ||||
|       const imageDataOne = getImage({width: 1, height: 1}) | ||||
|       const imageDataOne = getImage({ width: 1, height: 1 }) | ||||
|       image.addRepresentation({ | ||||
|         scaleFactor: 1.0, | ||||
|         dataURL: imageDataOne.dataUrl | ||||
|       }) | ||||
| 
 | ||||
|       const imageDataTwo = getImage({width: 2, height: 2}) | ||||
|       const imageDataTwo = getImage({ width: 2, height: 2 }) | ||||
|       image.addRepresentation({ | ||||
|         scaleFactor: 2.0, | ||||
|         dataURL: imageDataTwo.dataUrl | ||||
|       }) | ||||
| 
 | ||||
|       const imageDataThree = getImage({width: 3, height: 3}) | ||||
|       const imageDataThree = getImage({ width: 3, height: 3 }) | ||||
|       image.addRepresentation({ | ||||
|         scaleFactor: 3.0, | ||||
|         dataURL: imageDataThree.dataUrl | ||||
|  | @ -509,32 +509,32 @@ describe('nativeImage module', () => { | |||
|       }) | ||||
| 
 | ||||
|       expect(image.isEmpty()).to.be.false() | ||||
|       expect(image.getSize()).to.deep.equal({width: 1, height: 1}) | ||||
|       expect(image.getSize()).to.deep.equal({ width: 1, height: 1 }) | ||||
| 
 | ||||
|       expect(image.toDataURL({scaleFactor: 1.0})).to.equal(imageDataOne.dataUrl) | ||||
|       expect(image.toDataURL({scaleFactor: 2.0})).to.equal(imageDataTwo.dataUrl) | ||||
|       expect(image.toDataURL({scaleFactor: 3.0})).to.equal(imageDataThree.dataUrl) | ||||
|       expect(image.toDataURL({scaleFactor: 4.0})).to.equal(imageDataThree.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 1.0 })).to.equal(imageDataOne.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 2.0 })).to.equal(imageDataTwo.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 3.0 })).to.equal(imageDataThree.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 4.0 })).to.equal(imageDataThree.dataUrl) | ||||
|     }) | ||||
| 
 | ||||
|     it('supports adding a representation to an existing image', () => { | ||||
|       const imageDataOne = getImage({width: 1, height: 1}) | ||||
|       const imageDataOne = getImage({ width: 1, height: 1 }) | ||||
|       const image = nativeImage.createFromPath(imageDataOne.path) | ||||
| 
 | ||||
|       const imageDataTwo = getImage({width: 2, height: 2}) | ||||
|       const imageDataTwo = getImage({ width: 2, height: 2 }) | ||||
|       image.addRepresentation({ | ||||
|         scaleFactor: 2.0, | ||||
|         dataURL: imageDataTwo.dataUrl | ||||
|       }) | ||||
| 
 | ||||
|       const imageDataThree = getImage({width: 3, height: 3}) | ||||
|       const imageDataThree = getImage({ width: 3, height: 3 }) | ||||
|       image.addRepresentation({ | ||||
|         scaleFactor: 2.0, | ||||
|         dataURL: imageDataThree.dataUrl | ||||
|       }) | ||||
| 
 | ||||
|       expect(image.toDataURL({scaleFactor: 1.0})).to.equal(imageDataOne.dataUrl) | ||||
|       expect(image.toDataURL({scaleFactor: 2.0})).to.equal(imageDataTwo.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 1.0 })).to.equal(imageDataOne.dataUrl) | ||||
|       expect(image.toDataURL({ scaleFactor: 2.0 })).to.equal(imageDataTwo.dataUrl) | ||||
|     }) | ||||
|   }) | ||||
| }) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Samuel Attard
				Samuel Attard