Add initial NativeImage.addRepresentation specs
This commit is contained in:
		
					parent
					
						
							
								783b5e84f4
							
						
					
				
			
			
				commit
				
					
						17b70670f8
					
				
			
		
					 3 changed files with 27 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -249,4 +249,31 @@ describe('nativeImage module', () => {
 | 
			
		|||
      assert.equal(nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', 'logo.png')).getAspectRatio(), 2.8315789699554443)
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  describe('addRepresentation()', () => {
 | 
			
		||||
    it('supports adding a representation for a scale factor', () => {
 | 
			
		||||
      const image = nativeImage.createEmpty()
 | 
			
		||||
      image.addRepresentation({
 | 
			
		||||
        scaleFactor: 1.0,
 | 
			
		||||
        buffer: nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', '1x1.png')).toPNG()
 | 
			
		||||
      })
 | 
			
		||||
      image.addRepresentation({
 | 
			
		||||
        scaleFactor: 2.0,
 | 
			
		||||
        buffer: nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', '2x2.jpg')).toPNG()
 | 
			
		||||
      })
 | 
			
		||||
      image.addRepresentation({
 | 
			
		||||
        scaleFactor: 3.0,
 | 
			
		||||
        buffer: nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', '3x3.png')).toPNG()
 | 
			
		||||
      })
 | 
			
		||||
      image.addRepresentation({
 | 
			
		||||
        scaleFactor: 4.0,
 | 
			
		||||
        buffer: 'invalid'
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      assert.equal(image.toDataURL({scaleFactor: 1.0}), 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYlWNgAAIAAAUAAdafFs0AAAAASUVORK5CYII=')
 | 
			
		||||
      assert.equal(image.toDataURL({scaleFactor: 2.0}), 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFUlEQVQYlWP8////fwYGBgYmBigAAD34BABBrq9BAAAAAElFTkSuQmCC')
 | 
			
		||||
      assert.equal(image.toDataURL({scaleFactor: 3.0}), 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW/AAAADElEQVQYlWNgIAoAAAAnAAGZWEMnAAAAAElFTkSuQmCC')
 | 
			
		||||
      assert.equal(image.toDataURL({scaleFactor: 4.0}), 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW/AAAADElEQVQYlWNgIAoAAAAnAAGZWEMnAAAAAElFTkSuQmCC')
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue