fix(manifest): infer browser mode for public TS adapters (#115)
This commit is contained in:
1 parent
024d9908b3
commit
1e0e4cd660
2 files changed
+13
-4
No files matched your search
@@ -231,6 +231,7 @@ function scanTs(filePath: string, site: string): ManifestEntry {
|
||||
// Extract browser: false (some adapters bypass browser entirely)
|
||||
const browserMatch = src.match(/browser\s*:\s*(true|false)/);
|
||||
if (browserMatch) entry.browser = browserMatch[1] === 'true';
|
||||
else entry.browser = entry.strategy !== 'public';
|
||||
|
||||
// Extract columns
|
||||
const colMatch = src.match(/columns\s*:\s*\[([^\]]*)\]/);
|
||||
|
||||
+12
-4
@@ -1,18 +1,26 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { formatTimestamp, workStatusLabel } from './chaoxing.js';
|
||||
|
||||
function localDatePrefixFromMillis(ts: number): string {
|
||||
const d = new Date(ts);
|
||||
const yyyy = d.getFullYear();
|
||||
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
||||
const dd = String(d.getDate()).padStart(2, '0');
|
||||
return `${yyyy}-${mm}-${dd}`;
|
||||
}
|
||||
|
||||
describe('formatTimestamp', () => {
|
||||
it('formats millisecond timestamp', () => {
|
||||
// 2026-01-15 08:30 UTC+8
|
||||
const ts = new Date('2026-01-15T00:30:00Z').getTime();
|
||||
const result = formatTimestamp(ts);
|
||||
expect(result).toMatch(/2026-01-15/);
|
||||
expect(result).toMatch(new RegExp(`^${localDatePrefixFromMillis(ts)}\\s`));
|
||||
});
|
||||
|
||||
it('formats second timestamp', () => {
|
||||
const ts = Math.floor(new Date('2026-06-01T12:00:00Z').getTime() / 1000);
|
||||
const millis = new Date('2026-06-01T12:00:00Z').getTime();
|
||||
const ts = Math.floor(millis / 1000);
|
||||
const result = formatTimestamp(ts);
|
||||
expect(result).toMatch(/2026-06-01/);
|
||||
expect(result).toMatch(new RegExp(`^${localDatePrefixFromMillis(millis)}\\s`));
|
||||
});
|
||||
|
||||
it('returns empty for null/undefined/0', () => {
|
||||
|
||||
Reference in new issue
Block a user