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.2 KB
Raw Blame
import { describe, it, expect } from 'vitest';
import {
  CJK_COMMENTS,
  SELF_TEST,
  UNTESTED_HELPERS,
  load,
  problems,
  selfTest,
} from '../../scripts/check-source-bans.mjs';

const base = load();

describe('source bans', () => {
  it('passes on the current tree', () => {
    expect(problems(base)).toEqual([]);
  });

  it.each(Object.entries(SELF_TEST.caught))('catches %s', (_, [rel, text]) => {
    expect(problems({ ...base, [rel]: text })).not.toEqual([]);
  });

  it.each(Object.entries(SELF_TEST.ignored))(
    'leaves alone %s',
    (_, [rel, text]) => {
      expect(problems({ ...base, [rel]: text })).toEqual([]);
    },
  );

  it('fails a stale allowlist entry', () => {
    const [rel] = Object.keys(CJK_COMMENTS);
    expect(problems({ ...base, [rel]: '' })).toContainEqual(
      expect.stringContaining('listed in CJK_COMMENTS'),
    );
    const helper = UNTESTED_HELPERS[0];
    const name = helper.split('/').pop()!.replace(/\.ts$/, '');
    expect(
      problems({ ...base, [`tests/unit/${name}.test.ts`]: '' }),
    ).toContainEqual(expect.stringContaining('listed in UNTESTED_HELPERS'));
  });

  it('passes its own self-test', () => {
    expect(selfTest(base)).toEqual([]);
  });
});