Nativefier/src/helpers/convertToIcns.test.js

40 lines
885 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
function testConvertPng(pngName, done) {
if (os.platform() !== 'darwin') {
// Skip png conversion tests, OSX is required
done();
return;
}
convertToIcns(
path.join(__dirname, '../../', 'test-resources', pngName),
(error, icnsPath) => {
if (error) {
done(error);
return;
}
const stat = fs.statSync(icnsPath);
expect(stat.isFile()).toBe(true);
done();
},
);
}
describe('Get Icon Module', () => {
test('Can convert a rgb png to icns', (done) => {
testConvertPng('iconSample.png', done);
});
test('Can convert a grey png to icns', (done) => {
testConvertPng('iconSampleGrey.png', done);
});
});