mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-21 15:53:50 +02:00
fead: group member moderation ban export/import dialog (#1675)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
generateEmojiStyle,
|
||||
getEmojiFileName,
|
||||
getPrintFileName,
|
||||
getPrintLocalDate
|
||||
@@ -311,4 +312,47 @@ describe('Gallery Utils', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateEmojiStyle', () => {
|
||||
test('returns CSS with background url and animation', () => {
|
||||
const style = generateEmojiStyle(
|
||||
'https://example.com/emoji.png',
|
||||
10,
|
||||
4,
|
||||
'linear',
|
||||
100
|
||||
);
|
||||
expect(style).toContain("url('https://example.com/emoji.png')");
|
||||
expect(style).toContain('animation:');
|
||||
expect(style).toContain('steps(1)');
|
||||
});
|
||||
|
||||
test('uses 2 framesPerLine for frameCount <= 4', () => {
|
||||
const style = generateEmojiStyle('u', 10, 4, 'linear', 100);
|
||||
// frameSize = 1024/2 = 512
|
||||
expect(style).toContain('512px');
|
||||
});
|
||||
|
||||
test('uses 4 framesPerLine for frameCount 5-16', () => {
|
||||
const style = generateEmojiStyle('u', 10, 8, 'linear', 100);
|
||||
// frameSize = 1024/4 = 256
|
||||
expect(style).toContain('256px');
|
||||
});
|
||||
|
||||
test('uses 8 framesPerLine for frameCount > 16', () => {
|
||||
const style = generateEmojiStyle('u', 10, 20, 'linear', 100);
|
||||
// frameSize = 1024/8 = 128
|
||||
expect(style).toContain('128px');
|
||||
});
|
||||
|
||||
test('uses alternate for pingpong loopStyle', () => {
|
||||
const style = generateEmojiStyle('u', 10, 4, 'pingpong', 100);
|
||||
expect(style).toContain('alternate');
|
||||
});
|
||||
|
||||
test('uses none for non-pingpong loopStyle', () => {
|
||||
const style = generateEmojiStyle('u', 10, 4, 'linear', 100);
|
||||
expect(style).toMatch(/\bnone\b/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { removeFromArray } from '../array';
|
||||
import {
|
||||
removeFromArray,
|
||||
arraysMatch,
|
||||
moveArrayItem,
|
||||
replaceReactiveObject
|
||||
} from '../array';
|
||||
|
||||
describe('Array Utils', () => {
|
||||
describe('removeFromArray', () => {
|
||||
@@ -33,4 +38,91 @@ describe('Array Utils', () => {
|
||||
expect(arr).toEqual([1, 2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('arraysMatch', () => {
|
||||
test('returns true for identical arrays', () => {
|
||||
expect(arraysMatch([1, 2, 3], [1, 2, 3])).toBe(true);
|
||||
});
|
||||
|
||||
test('returns false for different lengths', () => {
|
||||
expect(arraysMatch([1, 2], [1, 2, 3])).toBe(false);
|
||||
});
|
||||
|
||||
test('returns false for different content', () => {
|
||||
expect(arraysMatch([1, 2], [1, 3])).toBe(false);
|
||||
});
|
||||
|
||||
test('returns true for empty arrays', () => {
|
||||
expect(arraysMatch([], [])).toBe(true);
|
||||
});
|
||||
|
||||
test('returns false for non-array first arg', () => {
|
||||
expect(arraysMatch(null, [])).toBe(false);
|
||||
});
|
||||
|
||||
test('returns false for non-array second arg', () => {
|
||||
expect(arraysMatch([], null)).toBe(false);
|
||||
});
|
||||
|
||||
test('deep-compares objects via JSON', () => {
|
||||
expect(arraysMatch([{ a: 1 }], [{ a: 1 }])).toBe(true);
|
||||
expect(arraysMatch([{ a: 1 }], [{ a: 2 }])).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('moveArrayItem', () => {
|
||||
test('moves item forward', () => {
|
||||
const arr = ['a', 'b', 'c', 'd'];
|
||||
moveArrayItem(arr, 0, 2);
|
||||
expect(arr).toEqual(['b', 'c', 'a', 'd']);
|
||||
});
|
||||
|
||||
test('moves item backward', () => {
|
||||
const arr = ['a', 'b', 'c', 'd'];
|
||||
moveArrayItem(arr, 3, 1);
|
||||
expect(arr).toEqual(['a', 'd', 'b', 'c']);
|
||||
});
|
||||
|
||||
test('no-ops when fromIndex equals toIndex', () => {
|
||||
const arr = [1, 2, 3];
|
||||
moveArrayItem(arr, 1, 1);
|
||||
expect(arr).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
test('no-ops for negative fromIndex', () => {
|
||||
const arr = [1, 2, 3];
|
||||
moveArrayItem(arr, -1, 0);
|
||||
expect(arr).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
test('no-ops for out-of-bounds toIndex', () => {
|
||||
const arr = [1, 2, 3];
|
||||
moveArrayItem(arr, 0, 5);
|
||||
expect(arr).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
test('no-ops for non-array input', () => {
|
||||
expect(() => moveArrayItem(null, 0, 1)).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('replaceReactiveObject', () => {
|
||||
test('replaces all keys from source', () => {
|
||||
const target = { a: 1, b: 2 };
|
||||
replaceReactiveObject(target, { c: 3 });
|
||||
expect(target).toEqual({ c: 3 });
|
||||
});
|
||||
|
||||
test('clears target when source is empty', () => {
|
||||
const target = { a: 1, b: 2 };
|
||||
replaceReactiveObject(target, {});
|
||||
expect(target).toEqual({});
|
||||
});
|
||||
|
||||
test('overwrites existing keys', () => {
|
||||
const target = { a: 1 };
|
||||
replaceReactiveObject(target, { a: 99, b: 2 });
|
||||
expect(target).toEqual({ a: 99, b: 2 });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user