| 1 | import { describe, expect, it } from 'vitest'; |
| 2 | |
| 3 | import { |
| 4 | attachmentKey, |
| 5 | attachmentTypeOf, |
| 6 | isInlineAttachment, |
| 7 | } from './attachments.js'; |
| 8 | |
| 9 | describe('attachmentKey', () |
| 10 | it('names an object, or the prefix of a repository', |
| 11 | expect(attachmentKey('repo_1 |
| 12 | 'attachments/repo_1/attachment_1', |
| 13 | ); |
| 14 | expect(attachmentKey('repo_1 |
| 15 | }); |
| 16 | }); |
| 17 | |
| 18 | describe('attachmentTypeOf', () |
| 19 | it('types a file by its extension, ignoring case', |
| 20 | expect(attachmentTypeOf('screenshot.PNG |
| 21 | expect(attachmentTypeOf('IMG_0001.HEIC |
| 22 | expect(attachmentTypeOf('build.log |
| 23 | expect(attachmentTypeOf('logs.tar.gz |
| 24 | }); |
| 25 | |
| 26 | it('refuses anything a browser could run, or without an extension', |
| 27 | for (const name |
| 28 | 'page.html', |
| 29 | 'icon.svg', |
| 30 | 'script.js', |
| 31 | 'README', |
| 32 | '.png', |
| 33 | ]) { |
| 34 | expect(attachmentTypeOf(name |
| 35 | } |
| 36 | }); |
| 37 | }); |
| 38 | |
| 39 | describe('isInlineAttachment', () |
| 40 | it('opens images and downloads everything else', |
| 41 | expect(isInlineAttachment('image/png |
| 42 | expect(isInlineAttachment('application/pdf |
| 43 | expect(isInlineAttachment('text/plain |
| 44 | }); |
| 45 | }); |