mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(flash board): add SWF posting support (#1145)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { normalizeDirectoryList, sortDirectoryBoardsByRank } from '../directory-list-utils';
|
||||
import { normalizeDirectoryList, sortDirectoryBoardsByRank, sortDirectoryLists } from '../directory-list-utils';
|
||||
|
||||
describe('directory-list-utils', () => {
|
||||
it('preserves board scores and uses them for ranking', () => {
|
||||
@@ -20,4 +20,36 @@ describe('directory-list-utils', () => {
|
||||
]);
|
||||
expect(sortDirectoryBoardsByRank(list?.boards ?? [])[0]?.address).toBe('higher-score.bso');
|
||||
});
|
||||
|
||||
it('orders the Flash directory with the classic board set', () => {
|
||||
expect(
|
||||
sortDirectoryLists([
|
||||
{ directoryCode: 'co', boards: [{ address: 'comics.bso' }] },
|
||||
{ directoryCode: 'f', boards: [{ address: 'flash-posting.bso' }] },
|
||||
{ directoryCode: 'a', boards: [{ address: 'anime.bso' }] },
|
||||
]).map((list) => list.directoryCode),
|
||||
).toEqual(['a', 'f', 'co']);
|
||||
});
|
||||
|
||||
it('preserves rules from the directory list', () => {
|
||||
const list = normalizeDirectoryList(
|
||||
{
|
||||
directoryCode: 'f',
|
||||
rules: ['Tag uploaded files.'],
|
||||
boards: [{ address: 'flash-posting.bso' }],
|
||||
},
|
||||
'f',
|
||||
{
|
||||
directories: {
|
||||
f: {
|
||||
directoryCode: 'f',
|
||||
title: '/f/ - Flash',
|
||||
rules: ['Ignored because defaults rules are not vendored.'],
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(list?.rules).toEqual(['Tag uploaded files.']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -98,6 +98,7 @@ describe('media-utils', () => {
|
||||
expect(getDisplayMediaInfoType('iframe', t)).toBe('translated:iframe');
|
||||
expect(getDisplayMediaInfoType('video', t)).toBe('translated:video');
|
||||
expect(getDisplayMediaInfoType('audio', t)).toBe('translated:audio');
|
||||
expect(getDisplayMediaInfoType('swf', t)).toBe('SWF');
|
||||
expect(getDisplayMediaInfoType('unknown', t)).toBe('translated:webpage');
|
||||
});
|
||||
|
||||
@@ -107,6 +108,7 @@ describe('media-utils', () => {
|
||||
expect(getHasThumbnail({ type: 'video', url: 'https://example.com/file.mp4' }, 'https://example.com/file.mp4')).toBe(true);
|
||||
expect(getHasThumbnail({ type: 'audio', url: 'https://example.com/file.mp3' }, 'https://example.com/file.mp3')).toBe(true);
|
||||
expect(getHasThumbnail({ type: 'gif', url: 'https://example.com/file.gif' }, 'https://example.com/file.gif')).toBe(true);
|
||||
expect(getHasThumbnail({ type: 'swf', url: 'https://example.com/file.swf' }, 'https://example.com/file.swf')).toBe(true);
|
||||
expect(getHasThumbnail({ thumbnail: 'https://example.com/thumb.png', type: 'webpage', url: 'https://example.com' }, 'https://example.com')).toBe(true);
|
||||
expect(
|
||||
getHasThumbnail(
|
||||
@@ -132,6 +134,7 @@ describe('media-utils', () => {
|
||||
expect(getLinkMediaInfo('https://example.com/file.png')).toMatchObject({ type: 'image' });
|
||||
expect(getLinkMediaInfo('https://example.com/file.mp4')).toMatchObject({ type: 'video' });
|
||||
expect(getLinkMediaInfo('https://example.com/file.mp3')).toMatchObject({ type: 'audio' });
|
||||
expect(getLinkMediaInfo('https://example.com/file.swf')).toMatchObject({ type: 'swf' });
|
||||
expect(getLinkMediaInfo('https://example.com/path')).toMatchObject({ type: 'webpage' });
|
||||
expect(getLinkMediaInfo('https://www.youtube.com/watch?v=abc123')).toEqual({
|
||||
patternThumbnailUrl: 'https://img.youtube.com/vi/abc123/0.jpg',
|
||||
@@ -201,6 +204,7 @@ describe('media-utils', () => {
|
||||
expect(getMediaDimensions({ type: 'audio', url: 'https://example.com/file.mp3' })).toBe('700x240');
|
||||
expect(getMediaDimensions({ linkHeight: 480, linkWidth: 640, type: 'image', url: 'https://example.com/file.png' })).toBe('640x480');
|
||||
expect(getMediaDimensions({ linkHeight: 720, linkWidth: 1280, type: 'video', url: 'https://example.com/file.mp4' })).toBe('1280x720');
|
||||
expect(getMediaDimensions({ linkHeight: 480, linkWidth: 640, type: 'swf', url: 'https://example.com/file.swf' })).toBe('640x480');
|
||||
expect(getMediaDimensions({ type: 'webpage', url: 'https://example.com' })).toBe('');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user