文件
mynode/packages/generator-joplin/generators/app/utils.test.js
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

51 行
1.8 KiB
JavaScript

const { packageNameFromPluginName, mergeIgnoreFile } = require('./utils');
describe('utils', () => {
test('packageNameFromPluginName', () => {
const testCases = [
['That\'s my plugin!', 'joplin-plugin-that-s-my-plugin'],
['with-dashes', 'joplin-plugin-with-dashes'],
['with.dots...', 'joplin-plugin-with-dots'],
['¡¡¡front dashes!!!', 'joplin-plugin-front-dashes'],
['That [will] [be] removed', 'joplin-plugin-that-will-be-removed'],
['very very very long name very very very long name very very very long name very very very long name very very very long name very very very long name very very very long name very very very long name very very very long name', 'joplin-plugin-very-very-very-long-name-very-very-very-long-name-very-very-very-long-name-very-very-very-long-name-very-very-very-long-name-very-very-very-long-name-very-very-very-long-name-very-very-very-long-name'],
];
for (const t of testCases) {
const input = t[0];
const expected = t[1];
const actual = packageNameFromPluginName(input);
expect(actual).toBe(expected);
}
let hasThrown = false;
try {
packageNameFromPluginName('');
} catch (error) {
hasThrown = true;
}
expect(hasThrown).toBe(true);
});
test('mergeIgnoreFile', () => {
const testCases = [
['line1\nline2\n', 'newline\n', 'line1\nline2\nnewline\n'],
['line1\nline2\n', 'line1\nnewline\n', 'line1\nline2\nnewline\n'],
['line1\r\nline2\r\n', 'line1\nnewline\n', 'line1\nline2\nnewline\n'],
['line1\nline2\n', 'line1\r\nnewline\r\n', 'line1\nline2\nnewline\n'],
['line1\r\nline2\r\n', 'line1\r\nnewline\r\n', 'line1\nline2\nnewline\n'],
];
for (const t of testCases) {
const userVersion = t[0];
const frameworkVersion = t[1];
const expected = t[2];
const actual = mergeIgnoreFile(frameworkVersion, userVersion);
expect(actual).toBe(expected);
}
});
});