Add failing spec for toPNG with scale factor
This commit is contained in:
parent
86babdd412
commit
8bc65ef495
1 changed files with 19 additions and 0 deletions
|
@ -104,6 +104,25 @@ describe('nativeImage module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('toPNG()', () => {
|
||||
it('returns a buffer at 1x scale factor', () => {
|
||||
const imageA = nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', 'logo.png'))
|
||||
const imageB = nativeImage.createFromBuffer(imageA.toPNG(), {
|
||||
width: imageA.getSize().width,
|
||||
height: imageA.getSize().height,
|
||||
scaleFactor: 2.0
|
||||
})
|
||||
assert.deepEqual(imageB.getSize(), {width: 269, height: 95})
|
||||
assert.equal(imageB.hasRepresentation(1.0), false)
|
||||
assert.equal(imageB.hasRepresentation(2.0), true)
|
||||
|
||||
const imageC = nativeImage.createFromBuffer(imageB.toPNG())
|
||||
assert.deepEqual(imageC.getSize(), {width: 538, height: 190})
|
||||
assert.equal(imageC.hasRepresentation(1.0), true)
|
||||
assert(imageB.toBitmap().equals(imageC.toBitmap()))
|
||||
})
|
||||
})
|
||||
|
||||
describe('createFromPath(path)', () => {
|
||||
it('returns an empty image for invalid paths', () => {
|
||||
assert(nativeImage.createFromPath('').isEmpty())
|
||||
|
|
Loading…
Add table
Reference in a new issue