From b46e48cae1da2c20387ed6a5b0ad1829c08289ca Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 6 Mar 2017 13:15:07 -0800 Subject: [PATCH] Add failing toDataURL spec --- spec/api-native-image-spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/api-native-image-spec.js b/spec/api-native-image-spec.js index e28b37bebfe6..90d184508183 100644 --- a/spec/api-native-image-spec.js +++ b/spec/api-native-image-spec.js @@ -79,6 +79,23 @@ describe('nativeImage module', () => { }) }) + describe('toDataURL()', () => { + it('returns a data URL 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) + + const imageC = nativeImage.createFromDataURL(imageB.toDataURL()) + assert.deepEqual(imageC.getSize(), {width: 538, height: 190}) + assert(imageB.toBitmap().equals(imageC.toBitmap())) + }) + }) + describe('createFromPath(path)', () => { it('returns an empty image for invalid paths', () => { assert(nativeImage.createFromPath('').isEmpty())