feat: auto-refresh calendar subscriptions
This commit is contained in:
@@ -92,6 +92,7 @@ describe('CalendarPanel',()=>{
|
||||
vi.useRealTimers()
|
||||
})
|
||||
it('keeps the newest week response when requests finish out of order',async()=>{
|
||||
vi.useFakeTimers();vi.setSystemTime(new Date(2026,8,20,10))
|
||||
const pending:Array<{url:string;resolve:(response:Response)=>void}>=[]
|
||||
const fetchMock=vi.fn((url:string)=>String(url).includes('calendar-events')?new Promise<Response>(resolve=>pending.push({url:String(url),resolve})):Promise.resolve(json(subscriptions)))
|
||||
const {host}=await mount(fetchMock)
|
||||
@@ -102,6 +103,7 @@ describe('CalendarPanel',()=>{
|
||||
pending[0].resolve(json({events:[{...events[0],id:'old',title:'旧一周'}],sources:[]}));await flush()
|
||||
expect(host.textContent).toContain('新一周')
|
||||
expect(host.textContent).not.toContain('旧一周')
|
||||
vi.useRealTimers()
|
||||
})
|
||||
it('supports week navigation and today',async()=>{
|
||||
const fetchMock=vi.fn((url:string)=>Promise.resolve(json(url.includes('calendar-events')?{events:[],sources:[]}:subscriptions)))
|
||||
|
||||
Reference in New Issue
Block a user