mirror of
https://github.com/purocean/yn.git
synced 2026-10-16 07:26:07 +08:00
test: make platform assertions resilient
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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.')
|
||||
})
|
||||
|
||||
|
||||
@@ -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")')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user