| | |
| | |
| | |
| | |
| | |
| |
|
| | import { describe, it, expect } from 'vitest'; |
| | import { |
| | clipboardHasImage, |
| | saveClipboardImage, |
| | cleanupOldClipboardImages, |
| | } from './clipboardUtils.js'; |
| |
|
| | describe('clipboardUtils', () => { |
| | describe('clipboardHasImage', () => { |
| | it('should return false on non-macOS platforms', async () => { |
| | if (process.platform !== 'darwin') { |
| | const result = await clipboardHasImage(); |
| | expect(result).toBe(false); |
| | } else { |
| | |
| | expect(true).toBe(true); |
| | } |
| | }); |
| |
|
| | it('should return boolean on macOS', async () => { |
| | if (process.platform === 'darwin') { |
| | const result = await clipboardHasImage(); |
| | expect(typeof result).toBe('boolean'); |
| | } else { |
| | |
| | expect(true).toBe(true); |
| | } |
| | }); |
| | }); |
| |
|
| | describe('saveClipboardImage', () => { |
| | it('should return null on non-macOS platforms', async () => { |
| | if (process.platform !== 'darwin') { |
| | const result = await saveClipboardImage(); |
| | expect(result).toBe(null); |
| | } else { |
| | |
| | expect(true).toBe(true); |
| | } |
| | }); |
| |
|
| | it('should handle errors gracefully', async () => { |
| | |
| | const result = await saveClipboardImage( |
| | '/invalid/path/that/does/not/exist', |
| | ); |
| |
|
| | if (process.platform === 'darwin') { |
| | |
| | expect(result === null || typeof result === 'string').toBe(true); |
| | } else { |
| | |
| | expect(result).toBe(null); |
| | } |
| | }); |
| | }); |
| |
|
| | describe('cleanupOldClipboardImages', () => { |
| | it('should not throw errors', async () => { |
| | |
| | await expect( |
| | cleanupOldClipboardImages('/path/that/does/not/exist'), |
| | ).resolves.not.toThrow(); |
| | }); |
| |
|
| | it('should complete without errors on valid directory', async () => { |
| | await expect(cleanupOldClipboardImages('.')).resolves.not.toThrow(); |
| | }); |
| | }); |
| | }); |
| |
|