Files
hkuds--deeptutor/web/tests/profile-naming.test.ts
wehub-resource-sync e4dcfc49aa
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:00:43 +08:00

33 lines
1.3 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { nextProfileName } from "../components/settings/profile-naming";
test("an auto name (matching the previous provider) tracks the new provider", () => {
assert.equal(nextProfileName("Brave", "Brave", "Jina"), "Jina");
});
test("an empty name is filled from the new provider", () => {
assert.equal(nextProfileName("", "Brave", "Jina"), "Jina");
assert.equal(nextProfileName(" ", "Brave", "Jina"), "Jina");
});
test("a user-customized name is never overwritten", () => {
assert.equal(nextProfileName("My search", "Brave", "Jina"), "My search");
});
test("never overwrites with an empty provider label (e.g. deselected)", () => {
assert.equal(nextProfileName("Brave", "Brave", ""), "Brave");
assert.equal(nextProfileName("My search", "Brave", ""), "My search");
});
test("matching against the previous label ignores surrounding whitespace", () => {
assert.equal(nextProfileName(" Brave ", "Brave", "Jina"), "Jina");
assert.equal(nextProfileName("Brave", " Brave ", "Jina"), "Jina");
});
test("a name equal to the new provider is effectively unchanged", () => {
// Re-selecting the same provider must not corrupt the name.
assert.equal(nextProfileName("Jina", "Jina", "Jina"), "Jina");
});