@abreen/tada 1.5.1 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/globals.ts +1 -1
- package/package.json +3 -2
- package/src/code/index.ts +5 -4
- package/src/index.ts +1 -1
- package/src/navigate/index.ts +27 -21
- package/src/navigate/lifecycle.ts +1 -1
- package/src/navigate/style.scss +2 -2
- package/src/search/index.ts +19 -16
- package/src/toc/index.ts +1 -1
- package/src/top/index.ts +3 -3
- package/src/util.ts +7 -6
- package/templates/_nav.html +1 -0
- package/bin/validators.test.ts +0 -205
- package/build/build-manifest.test.ts +0 -369
- package/build/code.test.ts +0 -272
- package/build/colors.test.ts +0 -66
- package/build/globals.test.ts +0 -100
- package/build/json-schema.test.ts +0 -57
- package/build/log.test.ts +0 -117
- package/build/markdown-plugins.test.ts +0 -456
- package/build/pagefind.test.ts +0 -192
- package/build/pdf-text.test.ts +0 -52
- package/build/reachability.test.ts +0 -80
- package/build/serve.test.ts +0 -59
- package/build/toc-plugin.test.ts +0 -120
- package/build/utils/content-files.test.ts +0 -56
- package/build/utils/derive-theme.test.ts +0 -111
- package/build/utils/file-types.test.ts +0 -79
- package/build/utils/front-matter.test.ts +0 -77
- package/build/utils/include.test.ts +0 -117
- package/build/utils/paths.test.ts +0 -91
- package/build/utils/trace-layout.test.ts +0 -570
- package/build/utils/trace-svg.test.ts +0 -425
- package/build/utils/trace.test.ts +0 -169
- package/build/validate-config-links.test.ts +0 -239
- package/build/validate-internal-links-plugin.test.ts +0 -134
- package/build/watch-reachability-state.test.ts +0 -198
- package/fonts/google-sans-code/ttf/GoogleSansCodeVariable-Italic.ttf +0 -0
- package/fonts/google-sans-code/ttf/GoogleSansCodeVariable.ttf +0 -0
- package/fonts/inter/ttf/InterVariable-Italic.ttf +0 -0
- package/src/anchor/index.test.ts +0 -64
- package/src/code/index.test.ts +0 -71
- package/src/header/index.test.ts +0 -89
- package/src/navigate/eligible.test.ts +0 -101
- package/src/navigate/index.test.ts +0 -82
- package/src/navigate/lifecycle.test.ts +0 -26
- package/src/print/index.test.ts +0 -71
- package/src/question/index.test.ts +0 -82
- package/src/search/index.test.ts +0 -203
- package/src/timezone/index.test.ts +0 -400
- package/src/toc/index.test.ts +0 -237
- package/src/top/index.test.ts +0 -46
- package/src/trace/index.test.ts +0 -554
- package/src/util.test.ts +0 -135
package/build/globals.test.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import createGlobals from './globals';
|
|
3
|
-
import type { SiteVariables } from './types';
|
|
4
|
-
|
|
5
|
-
const baseSite: SiteVariables = {
|
|
6
|
-
base: 'http://localhost:8080',
|
|
7
|
-
basePath: '/',
|
|
8
|
-
title: 'Test',
|
|
9
|
-
titlePostfix: ' - Test',
|
|
10
|
-
themeColor: 'hsl(195 70% 40%)',
|
|
11
|
-
defaultTimeZone: 'America/New_York',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function makeGlobals(subPath = 'index', site: Partial<SiteVariables> = {}) {
|
|
15
|
-
return createGlobals({}, { ...baseSite, ...site }, subPath);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe('createGlobals', () => {
|
|
19
|
-
test('isHomePage is true when subPath is "index"', () => {
|
|
20
|
-
expect(makeGlobals('index').isHomePage).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('isHomePage is false for other paths', () => {
|
|
24
|
-
expect(makeGlobals('about').isHomePage).toBe(false);
|
|
25
|
-
expect(makeGlobals('docs/guide').isHomePage).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('cx is an alias for classNames', () => {
|
|
29
|
-
const g = makeGlobals();
|
|
30
|
-
expect(g.cx).toBe(g.classNames);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('renderTimeZoneChooser includes hidden disabled select, inline script, and noscript', () => {
|
|
34
|
-
const g = makeGlobals('index', { defaultTimeZone: 'America/New_York' });
|
|
35
|
-
const html = g.renderTimeZoneChooser();
|
|
36
|
-
expect(html).toContain('<select class="time-zone" hidden disabled>');
|
|
37
|
-
expect(html).toContain('<noscript>Times shown in ET.</noscript>');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('isoDate', () => {
|
|
42
|
-
test('converts date string to ISO date', () => {
|
|
43
|
-
const g = makeGlobals();
|
|
44
|
-
expect(g.isoDate('2025-06-15')).toBe('2025-06-15');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('converts full datetime to date only', () => {
|
|
48
|
-
const g = makeGlobals();
|
|
49
|
-
expect(g.isoDate('2025-06-15T12:30:00Z')).toBe('2025-06-15');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('returns null for null/undefined/empty', () => {
|
|
53
|
-
const g = makeGlobals();
|
|
54
|
-
expect(g.isoDate(null)).toBe(null);
|
|
55
|
-
expect(g.isoDate(undefined)).toBe(null);
|
|
56
|
-
expect(g.isoDate('')).toBe(null);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe('readableDate', () => {
|
|
61
|
-
test('formats date as Month Day, Year', () => {
|
|
62
|
-
const g = makeGlobals();
|
|
63
|
-
expect(g.readableDate('2025-01-15T00:00:00Z')).toBe('January 15, 2025');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('strips leading zeros from day and month', () => {
|
|
67
|
-
const g = makeGlobals();
|
|
68
|
-
expect(g.readableDate('2025-03-05T00:00:00Z')).toBe('March 5, 2025');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('handles Date objects', () => {
|
|
72
|
-
const g = makeGlobals();
|
|
73
|
-
const result = g.readableDate(new Date('2025-12-25T00:00:00Z'));
|
|
74
|
-
expect(result).toBe('December 25, 2025');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('returns empty string for null/undefined/empty', () => {
|
|
78
|
-
const g = makeGlobals();
|
|
79
|
-
expect(g.readableDate(null)).toBe('');
|
|
80
|
-
expect(g.readableDate(undefined)).toBe('');
|
|
81
|
-
expect(g.readableDate('')).toBe('');
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe('classNames', () => {
|
|
86
|
-
test('returns truthy keys joined by space', () => {
|
|
87
|
-
const g = makeGlobals();
|
|
88
|
-
expect(g.classNames({ foo: true, bar: false, baz: 1 })).toBe('foo baz');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test('returns empty string when all falsy', () => {
|
|
92
|
-
const g = makeGlobals();
|
|
93
|
-
expect(g.classNames({ a: false, b: 0, c: '' })).toBe('');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('returns empty string for empty object', () => {
|
|
97
|
-
const g = makeGlobals();
|
|
98
|
-
expect(g.classNames({})).toBe('');
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import { compile, doValidation } from './json-schema';
|
|
3
|
-
|
|
4
|
-
const schema = {
|
|
5
|
-
type: 'object',
|
|
6
|
-
properties: { name: { type: 'string' }, age: { type: 'number' } },
|
|
7
|
-
required: ['name'],
|
|
8
|
-
additionalProperties: false,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
describe('compile', () => {
|
|
12
|
-
test('returns a validate function', () => {
|
|
13
|
-
const validator = compile(schema);
|
|
14
|
-
expect(typeof validator).toBe('function');
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe('doValidation', () => {
|
|
19
|
-
test('does not throw for valid input', () => {
|
|
20
|
-
const validator = compile(schema);
|
|
21
|
-
expect(() =>
|
|
22
|
-
doValidation(validator, { name: 'Alice' }, 'test.json'),
|
|
23
|
-
).not.toThrow();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('does not throw when optional fields are present', () => {
|
|
27
|
-
const validator = compile(schema);
|
|
28
|
-
expect(() =>
|
|
29
|
-
doValidation(validator, { name: 'Alice', age: 30 }, 'test.json'),
|
|
30
|
-
).not.toThrow();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('throws when required field is missing', () => {
|
|
34
|
-
const validator = compile(schema);
|
|
35
|
-
expect(() => doValidation(validator, {}, 'test.json')).toThrow(
|
|
36
|
-
'test.json failed validation',
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('throws with additionalProperties message', () => {
|
|
41
|
-
const validator = compile(schema);
|
|
42
|
-
expect(() =>
|
|
43
|
-
doValidation(validator, { name: 'Alice', extra: true }, 'test.json'),
|
|
44
|
-
).toThrow('unknown property "extra"');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('throws with field path in error', () => {
|
|
48
|
-
const nestedSchema = {
|
|
49
|
-
type: 'object',
|
|
50
|
-
properties: { name: { type: 'string' } },
|
|
51
|
-
};
|
|
52
|
-
const validator = compile(nestedSchema);
|
|
53
|
-
expect(() => doValidation(validator, { name: 123 }, 'data.json')).toThrow(
|
|
54
|
-
'data.json failed validation',
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
});
|
package/build/log.test.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import { makeLogger, getFlair } from './log';
|
|
3
|
-
|
|
4
|
-
function captureOutput(fn: () => void): { stdout: string; stderr: string } {
|
|
5
|
-
let stdout = '';
|
|
6
|
-
let stderr = '';
|
|
7
|
-
const origStdout = process.stdout.write;
|
|
8
|
-
const origStderr = process.stderr.write;
|
|
9
|
-
process.stdout.write = ((chunk: string) => {
|
|
10
|
-
stdout += chunk;
|
|
11
|
-
return true;
|
|
12
|
-
}) as typeof process.stdout.write;
|
|
13
|
-
process.stderr.write = ((chunk: string) => {
|
|
14
|
-
stderr += chunk;
|
|
15
|
-
return true;
|
|
16
|
-
}) as typeof process.stderr.write;
|
|
17
|
-
try {
|
|
18
|
-
fn();
|
|
19
|
-
} finally {
|
|
20
|
-
process.stdout.write = origStdout;
|
|
21
|
-
process.stderr.write = origStderr;
|
|
22
|
-
}
|
|
23
|
-
return { stdout, stderr };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
describe('makeLogger', () => {
|
|
27
|
-
test('creates a logger with default info level', () => {
|
|
28
|
-
const log = makeLogger('test');
|
|
29
|
-
expect(log.minLogLevel).toBe('info');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('throws on invalid log level', () => {
|
|
33
|
-
expect(() => makeLogger('test', 'verbose')).toThrow('Invalid log level');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('info writes to stdout', () => {
|
|
37
|
-
const log = makeLogger('test', 'info');
|
|
38
|
-
const { stdout } = captureOutput(() => log.info`hello world`);
|
|
39
|
-
expect(stdout).toContain('hello world');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('debug is suppressed at info level', () => {
|
|
43
|
-
const log = makeLogger('test', 'info');
|
|
44
|
-
const { stderr } = captureOutput(() => log.debug`should not appear`);
|
|
45
|
-
expect(stderr).toBe('');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('debug appears at debug level', () => {
|
|
49
|
-
const log = makeLogger('test', 'debug');
|
|
50
|
-
const { stderr } = captureOutput(() => log.debug`visible`);
|
|
51
|
-
expect(stderr).toContain('visible');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('warn writes to stdout', () => {
|
|
55
|
-
const log = makeLogger('test', 'warn');
|
|
56
|
-
const { stdout } = captureOutput(() => log.warn`caution`);
|
|
57
|
-
expect(stdout).toContain('caution');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('error writes to stdout', () => {
|
|
61
|
-
const log = makeLogger('test', 'error');
|
|
62
|
-
const { stdout } = captureOutput(() => log.error`failure`);
|
|
63
|
-
expect(stdout).toContain('failure');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('event always writes', () => {
|
|
67
|
-
const log = makeLogger('test', 'error');
|
|
68
|
-
const { stdout } = captureOutput(() => log.event`done`);
|
|
69
|
-
expect(stdout).toContain('done');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('followup writes strings', () => {
|
|
73
|
-
const log = makeLogger('test');
|
|
74
|
-
const { stdout } = captureOutput(() => log.followup(['line1', 'line2']));
|
|
75
|
-
expect(stdout).toContain('line1');
|
|
76
|
-
expect(stdout).toContain('line2');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('setMinLogLevel changes filtering', () => {
|
|
80
|
-
const log = makeLogger('test', 'info');
|
|
81
|
-
log.setMinLogLevel('error');
|
|
82
|
-
const { stdout } = captureOutput(() => log.info`suppressed`);
|
|
83
|
-
expect(stdout).toBe('');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('handles empty name', () => {
|
|
87
|
-
const log = makeLogger('');
|
|
88
|
-
expect(log.minLogLevel).toBe('info');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test('handles path-style name', () => {
|
|
92
|
-
const log = makeLogger('/path/to/module.ts');
|
|
93
|
-
const { stdout } = captureOutput(() => log.info`test`);
|
|
94
|
-
expect(stdout).toContain('test');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('handles file:// URL name', () => {
|
|
98
|
-
const log = makeLogger('file:///path/to/module.ts');
|
|
99
|
-
const { stdout } = captureOutput(() => log.info`test`);
|
|
100
|
-
expect(stdout).toContain('test');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('interpolates objects in template', () => {
|
|
104
|
-
const log = makeLogger('test');
|
|
105
|
-
const obj = { key: 'value' };
|
|
106
|
-
const { stdout } = captureOutput(() => log.info`data: ${obj}`);
|
|
107
|
-
expect(stdout).toContain('key');
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('getFlair', () => {
|
|
112
|
-
test('returns a non-empty string with emoji', () => {
|
|
113
|
-
const flair = getFlair();
|
|
114
|
-
expect(flair.length).toBeGreaterThan(0);
|
|
115
|
-
expect(flair).toContain('🎉');
|
|
116
|
-
});
|
|
117
|
-
});
|