mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-10-25 10:44:51 +00:00 
			
		
		
		
	* wip * wip * wip * wip * revert unnecessary changes * wip * refactor(frontend): enforce verbatimModuleSyntax * fix * refactor(frontend-shared): enforce verbatimModuleSyntax * wip * refactor(frontend-embed): enforce verbatimModuleSyntax * enforce consistent-type-imports * fix lint config * attemt to fix ci * fix lint * fix * fix * fix
		
			
				
	
	
		
			103 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			103 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| /*
 | |
|  * SPDX-FileCopyrightText: syuilo and misskey-project
 | |
|  * SPDX-License-Identifier: AGPL-3.0-only
 | |
|  */
 | |
| 
 | |
| import { describe, test, assert, afterEach } from 'vitest';
 | |
| import { render, cleanup, type RenderResult } from '@testing-library/vue';
 | |
| import './init';
 | |
| import * as Misskey from 'misskey-js';
 | |
| import { components } from '@/components/index.js';
 | |
| import { directives } from '@/directives/index.js';
 | |
| import MkMediaImage from '@/components/MkMediaImage.vue';
 | |
| 
 | |
| describe('MkMediaImage', () => {
 | |
| 	const renderMediaImage = (image: Partial<Misskey.entities.DriveFile>): RenderResult => {
 | |
| 		return render(MkMediaImage, {
 | |
| 			props: {
 | |
| 				image: {
 | |
| 					id: 'xxxxxxxx',
 | |
| 					createdAt: (new Date()).toJSON(),
 | |
| 					isSensitive: false,
 | |
| 					name: 'example.png',
 | |
| 					thumbnailUrl: null,
 | |
| 					url: '',
 | |
| 					type: 'application/octet-stream',
 | |
| 					size: 1,
 | |
| 					md5: '15eca7fba0480996e2245f5185bf39f2',
 | |
| 					blurhash: null,
 | |
| 					comment: null,
 | |
| 					properties: {},
 | |
| 					...image,
 | |
| 				} as DriveFile,
 | |
| 			},
 | |
| 			global: { directives, components },
 | |
| 		});
 | |
| 	};
 | |
| 
 | |
| 	afterEach(() => {
 | |
| 		cleanup();
 | |
| 	});
 | |
| 
 | |
| 	test('Attaching JPG should show no indicator', async () => {
 | |
| 		const mkMediaImage = renderMediaImage({
 | |
| 			type: 'image/jpeg',
 | |
| 		});
 | |
| 		const [gif, alt] = await Promise.all([
 | |
| 			mkMediaImage.queryByText('GIF'),
 | |
| 			mkMediaImage.queryByText('ALT'),
 | |
| 		]);
 | |
| 		assert.ok(!gif);
 | |
| 		assert.ok(!alt);
 | |
| 	});
 | |
| 
 | |
| 	test('Attaching GIF should show a GIF indicator', async () => {
 | |
| 		const mkMediaImage = renderMediaImage({
 | |
| 			type: 'image/gif',
 | |
| 		});
 | |
| 		const [gif, alt] = await Promise.all([
 | |
| 			mkMediaImage.queryByText('GIF'),
 | |
| 			mkMediaImage.queryByText('ALT'),
 | |
| 		]);
 | |
| 		assert.ok(gif);
 | |
| 		assert.ok(!alt);
 | |
| 	});
 | |
| 
 | |
| 	test('Attaching APNG should show a GIF indicator', async () => {
 | |
| 		const mkMediaImage = renderMediaImage({
 | |
| 			type: 'image/apng',
 | |
| 		});
 | |
| 		const [gif, alt] = await Promise.all([
 | |
| 			mkMediaImage.queryByText('GIF'),
 | |
| 			mkMediaImage.queryByText('ALT'),
 | |
| 		]);
 | |
| 		assert.ok(gif);
 | |
| 		assert.ok(!alt);
 | |
| 	});
 | |
| 
 | |
| 	test('Attaching image with an alt message should show an ALT indicator', async () => {
 | |
| 		const mkMediaImage = renderMediaImage({
 | |
| 			type: 'image/png',
 | |
| 			comment: 'Misskeyのロゴです',
 | |
| 		});
 | |
| 		const [gif, alt] = await Promise.all([
 | |
| 			mkMediaImage.queryByText('GIF'),
 | |
| 			mkMediaImage.queryByText('ALT'),
 | |
| 		]);
 | |
| 		assert.ok(!gif);
 | |
| 		assert.ok(alt);
 | |
| 	});
 | |
| 
 | |
| 	test('Attaching GIF image with an alt message should show a GIF and an ALT indicator', async () => {
 | |
| 		const mkMediaImage = renderMediaImage({
 | |
| 			type: 'image/gif',
 | |
| 			comment: 'Misskeyのロゴです',
 | |
| 		});
 | |
| 		const [gif, alt] = await Promise.all([
 | |
| 			mkMediaImage.queryByText('GIF'),
 | |
| 			mkMediaImage.queryByText('ALT'),
 | |
| 		]);
 | |
| 		assert.ok(gif);
 | |
| 		assert.ok(alt);
 | |
| 	});
 | |
| });
 |