34 lines
991 B
TypeScript
34 lines
991 B
TypeScript
/** @vitest-environment jsdom */
|
|
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
import { promptForAudienceProfileFields } from "../src/content/market/audience-profile-field-dialog";
|
|
|
|
describe("audience-profile-field-dialog", () => {
|
|
test("keeps an explicitly empty field selection empty", async () => {
|
|
const result = promptForAudienceProfileFields(
|
|
document,
|
|
[
|
|
{
|
|
headers: ["粉丝数", "观众画像-男性占比"],
|
|
label: "测试字段"
|
|
}
|
|
],
|
|
[]
|
|
);
|
|
|
|
const fields = Array.from(
|
|
document.querySelectorAll('[data-audience-profile-field-dialog-field="checkbox"]')
|
|
) as HTMLInputElement[];
|
|
expect(fields).toHaveLength(2);
|
|
expect(fields.every((field) => !field.checked)).toBe(true);
|
|
|
|
const saveButton = document.querySelector(
|
|
'[data-audience-profile-field-dialog-save="button"]'
|
|
) as HTMLButtonElement;
|
|
saveButton.click();
|
|
|
|
await expect(result).resolves.toEqual([]);
|
|
});
|
|
});
|