Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

1.4 KB
Raw Blame
import fs from 'node:fs';
import path from 'node:path';
import { describe, expect, it } from 'vitest';

const rustRoot = path.join(process.cwd(), 'src-tauri', 'src');
const windowSource = fs.readFileSync(
  path.join(rustRoot, 'app', 'window.rs'),
  'utf8',
);
const visibilitySources = [
  path.join(rustRoot, 'lib.rs'),
  path.join(rustRoot, 'app', 'setup.rs'),
  path.join(rustRoot, 'app', 'window.rs'),
].map((source) => fs.readFileSync(source, 'utf8'));

describe('Windows taskbar icon reapplication', () => {
  it('targets the large taskbar icon instead of only the small window icon', () => {
    expect(windowSource).toContain('ExtractIconExW');
    expect(windowSource).toContain('WM_SETICON');
    expect(windowSource).toContain('ICON_BIG');
  });

  it('reapplies the icon after every explicit window show', () => {
    for (const source of visibilitySources) {
      const shows = [...source.matchAll(/let _ = (\w+)\.show\(\);/g)];
      for (const show of shows) {
        const followingSource = source.slice(
          (show.index ?? 0) + show[0].length,
          (show.index ?? 0) + show[0].length + 160,
        );
        // Accept both reapply_window_icon(&window) and reapply_window_icon(window)
        // when the binding is already a reference (reveal_built_window).
        expect(followingSource).toMatch(
          new RegExp(`reapply_window_icon\\(&?${show[1]}\\);`),
        );
      }
    }
  });
});