fix(ui): isMacOS always returned false on Macs + plugin-logic tests (+49)
Coverage work found a 3rd real bug: isMacOS() compared os.name against the legacy 'Mac OS' string, but ua-parser-js v2 reports 'macOS' — so it was dead, and Mac users saw "Ctrl + k" instead of "⌘ + k" in the editor toolbar, search, and settings shortcut hints. Now accepts both 'macOS' and 'Mac OS'. Suites (via subagent, verified): via-servers (10 — power/popularity server selection), bad-words (9), syntaxHighlight tokenize (14), plugins/utils getEmoticonSearchStr (5), imageCompression formatFileSize/isCompressible (5), user-agent (6, now asserting the fixed behavior). Full suite now 501 tests, all passing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { getEmoticonSearchStr } from './utils';
|
||||
import { PackImageReader } from './custom-emoji';
|
||||
import { IEmoji } from './emoji';
|
||||
|
||||
test('getEmoticonSearchStr for a PackImageReader with a body returns shortcode + body', () => {
|
||||
const reader = new PackImageReader('cat', 'mxc://server/cat', { body: 'kitten' });
|
||||
assert.deepEqual(getEmoticonSearchStr(reader), [':cat:', 'kitten']);
|
||||
});
|
||||
|
||||
test('getEmoticonSearchStr for a PackImageReader without a body returns just the shortcode string', () => {
|
||||
const reader = new PackImageReader('cat', 'mxc://server/cat', {});
|
||||
assert.equal(getEmoticonSearchStr(reader), ':cat:');
|
||||
});
|
||||
|
||||
test('getEmoticonSearchStr ignores a non-string body on a PackImageReader', () => {
|
||||
const reader = new PackImageReader('cat', 'mxc://server/cat', {
|
||||
body: 123 as unknown as string,
|
||||
});
|
||||
assert.equal(getEmoticonSearchStr(reader), ':cat:');
|
||||
});
|
||||
|
||||
test('getEmoticonSearchStr for an IEmoji concats shortcode, label and shortcodes', () => {
|
||||
const emoji = {
|
||||
shortcode: 'smile',
|
||||
label: 'Smiling Face',
|
||||
shortcodes: ['smile', 'happy'],
|
||||
} as unknown as IEmoji;
|
||||
assert.deepEqual(getEmoticonSearchStr(emoji), [':smile:', 'Smiling Face', 'smile', 'happy']);
|
||||
});
|
||||
|
||||
test('getEmoticonSearchStr for an IEmoji without a shortcodes array returns shortcode + label', () => {
|
||||
const emoji = {
|
||||
shortcode: 'smile',
|
||||
label: 'Smiling Face',
|
||||
} as unknown as IEmoji;
|
||||
assert.deepEqual(getEmoticonSearchStr(emoji), [':smile:', 'Smiling Face']);
|
||||
});
|
||||
Reference in New Issue
Block a user