fix: keep reading bookmarks bound to route
This commit is contained in:
@@ -3,6 +3,7 @@ import { describe, it } from 'node:test'
|
||||
|
||||
import {
|
||||
createReadingBookmark,
|
||||
createReadingBookmarkSnapshot,
|
||||
getReadingBookmarkKey,
|
||||
readReadingBookmark,
|
||||
writeReadingBookmark
|
||||
@@ -62,6 +63,44 @@ describe('reading bookmarks', () => {
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
it('keeps delayed saves bound to the path captured before navigation', () => {
|
||||
const storage = createStorage()
|
||||
let currentPath = '/easy-vibe/zh-cn/page-a/'
|
||||
|
||||
const scheduledPath = currentPath
|
||||
currentPath = '/easy-vibe/zh-cn/page-b/'
|
||||
|
||||
writeReadingBookmark(
|
||||
storage,
|
||||
createReadingBookmarkSnapshot({
|
||||
path: scheduledPath,
|
||||
getTitle: () => '页面 A',
|
||||
getSection: () => '小节 A',
|
||||
getScrollY: () => 240,
|
||||
getProgress: () => 32,
|
||||
now: () => 777
|
||||
})
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
readReadingBookmark(storage, currentPath, 1000),
|
||||
null
|
||||
)
|
||||
assert.deepEqual(
|
||||
readReadingBookmark(storage, scheduledPath, 1000),
|
||||
{
|
||||
version: 1,
|
||||
path: scheduledPath,
|
||||
title: '页面 A',
|
||||
section: '小节 A',
|
||||
scrollY: 240,
|
||||
progress: 32,
|
||||
updatedAt: 777
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('normalizes invalid numeric values', () => {
|
||||
assert.deepEqual(
|
||||
createReadingBookmark({
|
||||
|
||||
Reference in New Issue
Block a user