Nativefier/src/helpers/convertToIcns.test.js

41 lines
965 B
JavaScript
Raw Normal View History

2018-05-24 08:34:18 +02:00
import fs from 'fs';
import os from 'os';
import path from 'path';
import convertToIcns from './convertToIcns';
// Prerequisite for test: to use OSX with sips, iconutil and imagemagick convert
2018-05-25 07:24:09 +02:00
function testConvertPng(pngName) {
2018-05-24 08:34:18 +02:00
if (os.platform() !== 'darwin') {
// Skip png conversion tests, OSX is required
2018-05-25 07:24:09 +02:00
return Promise.resolve();
2018-05-24 08:34:18 +02:00
}
2018-05-25 07:24:09 +02:00
return new Promise((resolve, reject) =>
convertToIcns(
path.join(__dirname, '../../', 'test-resources', pngName),
(error, icnsPath) => {
if (error) {
reject(error);
return;
}
2018-05-24 08:34:18 +02:00
2018-05-25 07:24:09 +02:00
const stat = fs.statSync(icnsPath);
2018-05-24 08:34:18 +02:00
2018-05-25 07:24:09 +02:00
expect(stat.isFile()).toBe(true);
resolve();
},
),
2018-05-24 08:34:18 +02:00
);
}
describe('Get Icon Module', () => {
2018-05-25 07:24:09 +02:00
test('Can convert a rgb png to icns', async () => {
await testConvertPng('iconSample.png');
2018-05-24 08:34:18 +02:00
});
2018-05-25 07:24:09 +02:00
test('Can convert a grey png to icns', async () => {
await testConvertPng('iconSampleGrey.png');
2018-05-24 08:34:18 +02:00
});
});