- 以 TabBar + 三个视图(任务/搜索/设置)替换原有 DashBoard/Side/HentaiSearch 单页结构 - 拆分 TaskView / TaskRow / TaskDetailSheet / SearchView / SettingsView / AuthScreen - 统一 theme.css 视觉规范,补 AppIcon 与缩略图工具 thumbnail.js 及其单测 - 提交弹层默认选中最高可用分辨率,缩略图加载失败走占位 - E站搜索结果与远端抽屉补回「在线看」入口
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import {ehThumbnailUrl, pickDefaultResolution} from '../src/utils/thumbnail.js'
|
|
|
|
test('remote thumbnail paths are wrapped with the auth code', () => {
|
|
const url = ehThumbnailUrl('samples/thumb.png', 'abc123')
|
|
assert.match(url, /^https:\/\/downloader\.lionwebsite\.xyz\/GalleryManage\/ehThumbnail\?/)
|
|
assert.match(url, /path=samples%2Fthumb\.png/)
|
|
assert.match(url, /AuthCode=abc123/)
|
|
})
|
|
|
|
test('a missing thumbnail path produces no url', () => {
|
|
assert.equal(ehThumbnailUrl('', 'abc123'), '')
|
|
assert.equal(ehThumbnailUrl(undefined, 'abc123'), '')
|
|
})
|
|
|
|
test('the original resolution is preselected when offered', () => {
|
|
const chosen = pickDefaultResolution({
|
|
'800x': '37.53MiB',
|
|
'1280x': '66.57MiB',
|
|
'2560x': '84.01MiB',
|
|
'Original': '498.2MiB',
|
|
})
|
|
assert.equal(chosen, 'Original')
|
|
})
|
|
|
|
test('the original label is matched case-insensitively', () => {
|
|
assert.equal(pickDefaultResolution({'800x': '1MiB', 'original': '2MiB'}), 'original')
|
|
})
|
|
|
|
test('without an original the largest entry wins across units', () => {
|
|
const chosen = pickDefaultResolution({
|
|
'800x': '37.53MiB',
|
|
'2560x': '84.01MiB',
|
|
'2160x': '1.2GiB',
|
|
})
|
|
assert.equal(chosen, '2160x')
|
|
})
|
|
|
|
test('an empty or absent resolution map selects nothing', () => {
|
|
assert.equal(pickDefaultResolution({}), '')
|
|
assert.equal(pickDefaultResolution(undefined), '')
|
|
})
|
|
|
|
test('unparseable sizes fall back to the first entry instead of throwing', () => {
|
|
assert.equal(pickDefaultResolution({'800x': 'unknown', '1280x': 'unknown'}), '800x')
|
|
})
|