additional tests for createFromBuffer

This commit is contained in:
gellert 2016-12-14 00:18:24 +01:00
parent a609e52a14
commit 7ceb8d1ab8
2 changed files with 14 additions and 1 deletions

View file

@ -149,7 +149,8 @@ console.log(image)
Returns `NativeImage`
Creates a new `NativeImage` instance from `buffer`. The default `scaleFactor` is
1.0. The `width` and `height` options are **required** for bitmap buffers.
1.0. The `width` and `height` options are **required** and only used for bitmap
buffers.
### `nativeImage.createFromDataURL(dataURL)`

View file

@ -29,6 +29,18 @@ describe('nativeImage module', () => {
const imageD = nativeImage.createFromBuffer(imageA.toBitmap(),
{width: 538, height: 190})
assert.deepEqual(imageD.getSize(), {width: 538, height: 190})
const imageE = nativeImage.createFromBuffer(imageA.toBitmap(),
{width: 100, height: 200})
assert.deepEqual(imageE.getSize(), {width: 100, height: 200})
const imageF = nativeImage.createFromBuffer(imageA.toPNG(),
{width: 100, height: 200})
assert.deepEqual(imageF.getSize(), {width: 538, height: 190})
const imageG = nativeImage.createFromBuffer(imageA.toJPEG(100),
{width: 100, height: 200})
assert.deepEqual(imageG.getSize(), {width: 538, height: 190})
})
})