 8d06a6475e
			
		
	
	8d06a6475e
	
	
	
		
			
			* chore: 著作権とライセンスについての情報を各ファイルに追加する * chore: Add the SPDX information to each file Add copyright and licensing information as defined in version 3.0 of the REUSE Specification. * tweak format --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * chore: Add SPDX-License-Identifier [skip ci] * add missing SPDX-License-Identifier * remove unused file --------- Co-authored-by: Shun Sakai <sorairolake@protonmail.ch> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com>
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| /*
 | |
|  * SPDX-FileCopyrightText: syuilo and other misskey contributors
 | |
|  * SPDX-License-Identifier: AGPL-3.0-only
 | |
|  */
 | |
| 
 | |
| import { describe, test, expect } from '@jest/globals';
 | |
| import { contentDisposition } from '@/misc/content-disposition.js';
 | |
| import { correctFilename } from '@/misc/correct-filename.js';
 | |
| 
 | |
| describe('misc:content-disposition', () => {
 | |
| 	test('inline', () => {
 | |
| 		expect(contentDisposition('inline', 'foo bar')).toBe('inline; filename=\"foo_bar\"; filename*=UTF-8\'\'foo%20bar');
 | |
| 	});
 | |
| 	test('attachment', () => {
 | |
| 		expect(contentDisposition('attachment', 'foo bar')).toBe('attachment; filename=\"foo_bar\"; filename*=UTF-8\'\'foo%20bar');
 | |
| 	});
 | |
| 	test('non ascii', () => {
 | |
| 		expect(contentDisposition('attachment', 'ファイル名')).toBe('attachment; filename=\"_____\"; filename*=UTF-8\'\'%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%90%8D');
 | |
| 	});
 | |
| });
 | |
| 
 | |
| describe('misc:correct-filename', () => {
 | |
| 	test('simple', () => {
 | |
| 		expect(correctFilename('filename', 'jpg')).toBe('filename.jpg');
 | |
| 	});
 | |
| 	test('with same ext', () => {
 | |
| 		expect(correctFilename('filename.jpg', 'jpg')).toBe('filename.jpg');
 | |
| 	});
 | |
| 	test('.ext', () => {
 | |
| 		expect(correctFilename('filename.jpg', '.jpg')).toBe('filename.jpg');
 | |
| 	});
 | |
| 	test('with different ext', () => {
 | |
| 		expect(correctFilename('filename.webp', 'jpg')).toBe('filename.webp.jpg');
 | |
| 	});
 | |
| 	test('non ascii with space', () => {
 | |
| 		expect(correctFilename('ファイル 名前', 'jpg')).toBe('ファイル 名前.jpg');
 | |
| 	});
 | |
| 	test('jpeg', () => {
 | |
| 		expect(correctFilename('filename.jpeg', 'jpg')).toBe('filename.jpeg');
 | |
| 	});
 | |
| 	test('tiff', () => {
 | |
| 		expect(correctFilename('filename.tiff', 'tif')).toBe('filename.tiff');
 | |
| 	});
 | |
| 	test('null ext', () => {
 | |
| 		expect(correctFilename('filename', null)).toBe('filename.unknown');
 | |
| 	});
 | |
| });
 |