Recently Written · git

scan-subread

PDF reader that follows an audiobook with the SubRead suite

git clone https://github.com/equwal/scan-subread

Log | Files | Refs


test/suite.test.ts (2731 bytes)

1 import { describe, expect, it } from 'vitest';
2 import {
3   ANKI_RELEASES,
4   DICTIONARY_RELEASES,
5   OVERLAY_RELEASES,
6   SUBREAD_RELEASES,
7 } from '../src/messages';
8 import type { SuiteApps } from '../src/subread';
9 import { suiteChecklist } from '../src/suite';
10 
11 const openOverlay = { id: 'open-overlay', text: 'Open SubRead Overlay' };
12 
13 const none: SuiteApps = {
14   overlay: false,
15   overlayDebug: false,
16   subread: null,
17   anki: false,
18   dictionaries: 0,
19 };
20 
21 describe('suiteChecklist', () => {
22   it('links each missing app to its releases', () => {
23     expect(suiteChecklist(none, undefined)).toEqual([
24       {
25         ok: false,
26         text: 'SubRead Overlay: not installed.',
27         link: { href: OVERLAY_RELEASES, text: 'Get SubRead Overlay' },
28       },
29       {
30         ok: false,
31         text: 'Dictionary apps: none.',
32         link: { href: DICTIONARY_RELEASES, text: 'Get SubRead Dictionary' },
33       },
34       {
35         ok: false,
36         text: 'SubRead: not installed.',
37         link: { href: SUBREAD_RELEASES, text: 'Get SubRead' },
38       },
39       {
40         ok: false,
41         text: 'SubRead Anki: not installed.',
42         link: { href: ANKI_RELEASES, text: 'Get SubRead Anki' },
43       },
44     ]);
45   });
46 
47   it('shows the phone of the test: the overlay without notification access', () => {
48     const phone: SuiteApps = {
49       overlay: true,
50       overlayDebug: false,
51       subread: '0.9.1',
52       anki: true,
53       dictionaries: 3,
54     };
55     expect(suiteChecklist(phone, 'no_notification_access')).toEqual([
56       { ok: false, text: 'SubRead Overlay: no notification access.', action: openOverlay },
57       { ok: true, text: 'Dictionary apps: 3.' },
58       { ok: true, text: 'SubRead 0.9.1: installed.' },
59       { ok: true, text: 'SubRead Anki: installed.' },
60     ]);
61   });
62 
63   it('takes the notification access of the overlay from the last player state', () => {
64     const debug = { ...none, overlayDebug: true };
65     const overlay = (error: string | null | undefined) => suiteChecklist(debug, error)[0];
66     expect(overlay(undefined)).toEqual({
67       ok: true,
68       text: 'SubRead Overlay: installed.',
69       action: openOverlay,
70     });
71     const access = {
72       ok: true,
73       text: 'SubRead Overlay: installed, with notification access.',
74       action: openOverlay,
75     };
76     expect(overlay(null)).toEqual(access);
77     expect(overlay('no_player')).toEqual(access);
78     expect(overlay('no_overlay')).toEqual({
79       ok: false,
80       text: 'SubRead Overlay: does not answer.',
81       action: openOverlay,
82     });
83   });
84 
85   it('names SubRead without a version name', () => {
86     expect(suiteChecklist({ ...none, subread: '' }, undefined)[2]).toEqual({
87       ok: true,
88       text: 'SubRead: installed.',
89     });
90   });
91 });