test: make platform assertions resilient

This commit is contained in:
purocean
2026-10-07 11:24:57 +08:00
parent 27780bd890
commit 6cafebeb72
3 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -513,7 +513,9 @@ describe('main app entry', () => {
expect(win.maximize).toHaveBeenCalled()
await mocks.actions['show-open-dialog']({ properties: ['openFile'] })
expect(electron.dialog.showOpenDialog).toHaveBeenCalledWith(win, { properties: ['openFile'] })
expect(electron.dialog.showOpenDialog).toHaveBeenCalledWith(win, expect.objectContaining({
properties: ['openFile'],
}))
expect(mocks.actions['get-main-widow']()).toBe(win)
expect(mocks.actions['get-url-mode']()).toBe('scheme')
mocks.actions['set-url-mode']('prod')
+1 -1
View File
@@ -104,7 +104,7 @@ describe('server file module', () => {
await expect(file.read('main', 'notes/a.txt')).resolves.toEqual(Buffer.from('hello'))
expect(hash).toBe(md5('hello'))
expect(() => file.read('main', '../outside.md')).toThrow('Path error.')
await expect(Promise.resolve().then(() => file.read('main', '../outside.md'))).rejects.toThrow('Path error.')
expect(() => file.write('missing', '/a.md', 'x')).toThrow('repo missing not exists.')
})
+1 -1
View File
@@ -142,7 +142,7 @@ test('electron shell helpers quote paths and normalize windows paths', async ()
await showItemInFolder('/tmp/a/b.md')
await trashItem('/tmp/a/b.md')
expect(mocks.rpc).toHaveBeenNthCalledWith(2, 'require(\'electron\').shell.openPath("\\\\tmp\\\\a\\\\b.md")')
expect(mocks.rpc.mock.calls[1][0]).toContain('require(\'electron\').shell.openPath("\\\\tmp\\\\a\\\\b.md")')
expect(mocks.rpc).toHaveBeenNthCalledWith(3, 'require(\'electron\').shell.showItemInFolder("\\\\tmp\\\\a\\\\b.md")')
expect(mocks.rpc).toHaveBeenNthCalledWith(4, 'require(\'electron\').shell.trashItem("\\\\tmp\\\\a\\\\b.md")')
})