forked from boos/BoosAPI
fix desktop tray icon telegram topics and checkin intervals
This commit is contained in:
@@ -21,13 +21,14 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe('generateDesktopIconAssets', () => {
|
||||
it('writes rounded desktop icon outputs for build and runtime usage', async () => {
|
||||
it('writes rounded desktop icon outputs and a tray template asset', async () => {
|
||||
const { generateDesktopIconAssets } = await import('./generate-icons.mjs');
|
||||
|
||||
const dir = await makeTempDir();
|
||||
const sourcePath = join(dir, 'logo.png');
|
||||
const buildOutputPath = join(dir, 'build.png');
|
||||
const webOutputPath = join(dir, 'desktop-icon.png');
|
||||
const trayTemplateOutputPath = join(dir, 'desktop-tray-template.png');
|
||||
|
||||
await sharp({
|
||||
create: {
|
||||
@@ -42,15 +43,19 @@ describe('generateDesktopIconAssets', () => {
|
||||
sourcePath,
|
||||
buildOutputPath,
|
||||
webOutputPath,
|
||||
trayTemplateOutputPath,
|
||||
});
|
||||
|
||||
const buildMeta = await sharp(buildOutputPath).metadata();
|
||||
const webMeta = await sharp(webOutputPath).metadata();
|
||||
const trayMeta = await sharp(trayTemplateOutputPath).metadata();
|
||||
|
||||
expect(buildMeta.width).toBe(512);
|
||||
expect(buildMeta.height).toBe(512);
|
||||
expect(webMeta.width).toBe(512);
|
||||
expect(webMeta.height).toBe(512);
|
||||
expect(trayMeta.width).toBe(512);
|
||||
expect(trayMeta.height).toBe(512);
|
||||
|
||||
const { data, info } = await sharp(buildOutputPath)
|
||||
.ensureAlpha()
|
||||
@@ -64,5 +69,18 @@ describe('generateDesktopIconAssets', () => {
|
||||
|
||||
expect(await sharp(buildOutputPath).png().toBuffer())
|
||||
.toEqual(await sharp(webOutputPath).png().toBuffer());
|
||||
|
||||
const trayBuffer = await sharp(trayTemplateOutputPath)
|
||||
.ensureAlpha()
|
||||
.raw()
|
||||
.toBuffer({ resolveWithObject: true });
|
||||
|
||||
expect(alphaAt(trayBuffer.data, trayBuffer.info.width, 0, 0)).toBe(0);
|
||||
expect(alphaAt(trayBuffer.data, trayBuffer.info.width, Math.floor(trayBuffer.info.width / 2), Math.floor(trayBuffer.info.height / 2))).toBe(255);
|
||||
|
||||
const trayCenterOffset = (Math.floor(trayBuffer.info.height / 2) * trayBuffer.info.width + Math.floor(trayBuffer.info.width / 2)) * 4;
|
||||
expect(trayBuffer.data[trayCenterOffset]).toBe(0);
|
||||
expect(trayBuffer.data[trayCenterOffset + 1]).toBe(0);
|
||||
expect(trayBuffer.data[trayCenterOffset + 2]).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user