test: unskip file reader utilities

This commit is contained in:
purocean
2026-05-02 17:13:40 +08:00
parent 78d3ab3605
commit cfbbf1d72e
4 changed files with 10 additions and 6 deletions
+3
View File
@@ -37,6 +37,9 @@ describe('renderer action registry', () => {
action.removeAction('alpha')
expect(action.getAction('alpha')).toBeUndefined()
expect(action.getRawActions().map(item => item.name)).toEqual(['beta'])
action.removeAction('missing')
expect(action.getRawActions().map(item => item.name)).toEqual(['beta'])
})
test('applies action tappers to cloned actions', async () => {
+1
View File
@@ -3,6 +3,7 @@ import * as ioc from '@fe/core/ioc'
test('ioc usage', () => {
expect(ioc.get('ACTION_AFTER_RUN')).toEqual([])
ioc.remove('ACTION_AFTER_RUN', null)
ioc.removeWhen('ACTION_AFTER_RUN', () => true)
ioc.register('ACTION_AFTER_RUN', 'test')
ioc.register('ACTION_AFTER_RUN', 'test1')
expect(ioc.get('ACTION_AFTER_RUN')).toEqual(['test', 'test1'])
@@ -84,8 +84,10 @@ describe('renderer keybinding utilities', () => {
const keybinding = await import('@fe/core/keybinding')
expect(keybinding.matchKeys(keyboardEvent('keydown', { key: 'o', code: 'KeyO', ctrlKey: true }), ['CtrlCmd', 'O'])).toBe(true)
expect(keybinding.matchKeys(keyboardEvent('keydown', { key: 'o', code: 'KeyO' }), ['CtrlCmd', 'O'])).toBe(false)
expect(keybinding.matchKeys(keyboardEvent('keydown', { key: '1', code: 'Digit1', ctrlKey: true }), ['Ctrl', '1'])).toBe(true)
expect(keybinding.matchKeys(keyboardEvent('keydown', { key: 'ArrowUp', code: 'ArrowUp' }), ['up'])).toBe(true)
expect(keybinding.matchKeys(keyboardEvent('keydown', { key: 'o', code: 'KeyO' }), ['P'])).toBe(false)
expect(keybinding.matchKeys(keyboardEvent('keydown', { key: 'o', code: 'KeyO', altKey: true }), ['Alt', 'O'])).toBe(true)
expect(keybinding.matchKeys(keyboardEvent('keydown', { key: 'o', code: 'KeyO', shiftKey: true }), ['Shift', 'O'])).toBe(true)
expect(keybinding.matchKeys(keyboardEvent('keydown', { key: 'o', code: 'KeyO', metaKey: true }), ['Win', 'O'])).toBe(true)
@@ -136,6 +138,7 @@ describe('renderer keybinding utilities', () => {
actionMocks.actions = [
{ name: 'disabled', keys: ['CtrlCmd', 'O'], when: () => false },
{ name: 'no-keys' },
{ name: 'open', keys: ['CtrlCmd', 'O'] },
{ name: 'later', keys: ['CtrlCmd', 'O'] },
]
+3 -6
View File
@@ -136,8 +136,7 @@ describe('pure utilities', () => {
})
describe('fileToBase64URL', () => {
test.skip('should convert File to base64 URL', async () => {
// Skipped: requires browser FileReader API
test('should convert File to base64 URL', async () => {
const file = new File(['Hello World'], 'test.txt', { type: 'text/plain' })
const base64URL = await fileToBase64URL(file)
@@ -145,8 +144,7 @@ describe('pure utilities', () => {
expect(base64URL).toContain('SGVsbG8gV29ybGQ=')
})
test.skip('should convert Blob to base64 URL', async () => {
// Skipped: requires browser FileReader API
test('should convert Blob to base64 URL', async () => {
const blob = new Blob(['Test content'], { type: 'text/plain' })
const base64URL = await fileToBase64URL(blob)
@@ -154,8 +152,7 @@ describe('pure utilities', () => {
expect(base64URL).toContain('VGVzdCBjb250ZW50')
})
test.skip('should handle empty file', async () => {
// Skipped: requires browser FileReader API
test('should handle empty file', async () => {
const file = new File([], 'empty.txt', { type: 'text/plain' })
const base64URL = await fileToBase64URL(file)