@@ -29,7 +29,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should export PRIVACY_SETTINGS_DEFAULT with all false and null portrait", () => {
|
||||
expect(PRIVACY_SETTINGS_DEFAULT).toEqual({
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: null,
|
||||
});
|
||||
});
|
||||
@@ -37,7 +36,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should export PRIVACY_SETTING_KEYS as frozen array including portrait fallback", () => {
|
||||
expect(PRIVACY_SETTING_KEYS).toEqual([
|
||||
"reactionCamEnabled",
|
||||
"hpReactiveCamStylingEnabled",
|
||||
"customPortraitFallback",
|
||||
]);
|
||||
expect(Object.isFrozen(PRIVACY_SETTING_KEYS)).toBe(true);
|
||||
@@ -46,7 +44,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should export FEATURE_NAME_MAP as frozen object", () => {
|
||||
expect(FEATURE_NAME_MAP).toEqual({
|
||||
reactionCam: "reactionCamEnabled",
|
||||
hpReactiveCamStyling: "hpReactiveCamStylingEnabled",
|
||||
});
|
||||
expect(Object.isFrozen(FEATURE_NAME_MAP)).toBe(true);
|
||||
});
|
||||
@@ -62,19 +59,6 @@ describe("privacy-settings contract", () => {
|
||||
const result = createPrivacySettings({ reactionCamEnabled: true });
|
||||
expect(result).toEqual({
|
||||
reactionCamEnabled: true,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("should allow both boolean settings to be overridden", () => {
|
||||
const result = createPrivacySettings({
|
||||
reactionCamEnabled: true,
|
||||
hpReactiveCamStylingEnabled: true,
|
||||
});
|
||||
expect(result).toEqual({
|
||||
reactionCamEnabled: true,
|
||||
hpReactiveCamStylingEnabled: true,
|
||||
customPortraitFallback: null,
|
||||
});
|
||||
});
|
||||
@@ -84,7 +68,6 @@ describe("privacy-settings contract", () => {
|
||||
const result = createPrivacySettings({ customPortraitFallback: dataURL });
|
||||
expect(result).toEqual({
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: dataURL,
|
||||
});
|
||||
});
|
||||
@@ -102,7 +85,6 @@ describe("privacy-settings contract", () => {
|
||||
});
|
||||
expect(result).toEqual({
|
||||
reactionCamEnabled: true,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: null,
|
||||
});
|
||||
});
|
||||
@@ -112,7 +94,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should accept valid settings with all false", () => {
|
||||
const valid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
};
|
||||
expect(isValidPrivacySettings(valid)).toEqual(valid);
|
||||
});
|
||||
@@ -120,7 +101,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should accept valid settings with all true", () => {
|
||||
const valid = {
|
||||
reactionCamEnabled: true,
|
||||
hpReactiveCamStylingEnabled: true,
|
||||
};
|
||||
expect(isValidPrivacySettings(valid)).toEqual(valid);
|
||||
});
|
||||
@@ -128,7 +108,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should accept valid settings with mixed values", () => {
|
||||
const valid = {
|
||||
reactionCamEnabled: true,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
};
|
||||
expect(isValidPrivacySettings(valid)).toEqual(valid);
|
||||
});
|
||||
@@ -164,7 +143,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should throw TypeError for unknown keys", () => {
|
||||
const invalid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
extraKey: "invalid",
|
||||
};
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(TypeError);
|
||||
@@ -174,7 +152,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should throw TypeError when reactionCamEnabled is not boolean", () => {
|
||||
const invalid = {
|
||||
reactionCamEnabled: "not a boolean",
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
};
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(TypeError);
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(
|
||||
@@ -185,7 +162,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should throw TypeError when reactionCamEnabled is a number", () => {
|
||||
const invalid = {
|
||||
reactionCamEnabled: 1,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
};
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(TypeError);
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(
|
||||
@@ -193,28 +169,6 @@ describe("privacy-settings contract", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should throw TypeError when hpReactiveCamStylingEnabled is not boolean", () => {
|
||||
const invalid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: "not a boolean",
|
||||
};
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(TypeError);
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(
|
||||
"hpReactiveCamStylingEnabled must be a boolean"
|
||||
);
|
||||
});
|
||||
|
||||
it("should throw TypeError when hpReactiveCamStylingEnabled is null", () => {
|
||||
const invalid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: null,
|
||||
};
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(TypeError);
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(
|
||||
"hpReactiveCamStylingEnabled must be a boolean"
|
||||
);
|
||||
});
|
||||
|
||||
it("should accept settings with only reactionCamEnabled (backward compatible)", () => {
|
||||
// Backward compatibility: settings without all keys are accepted
|
||||
const valid = {
|
||||
@@ -223,14 +177,6 @@ describe("privacy-settings contract", () => {
|
||||
expect(() => isValidPrivacySettings(valid)).not.toThrow();
|
||||
});
|
||||
|
||||
it("should accept settings with only hpReactiveCamStylingEnabled (backward compatible)", () => {
|
||||
// Backward compatibility: settings without all keys are accepted
|
||||
const valid = {
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
};
|
||||
expect(() => isValidPrivacySettings(valid)).not.toThrow();
|
||||
});
|
||||
|
||||
it("should accept empty object (backward compatible)", () => {
|
||||
// Backward compatibility: empty object is accepted
|
||||
expect(() => isValidPrivacySettings({})).not.toThrow();
|
||||
@@ -242,12 +188,6 @@ describe("privacy-settings contract", () => {
|
||||
expect(validateSettingKey("reactionCamEnabled")).toBe("reactionCamEnabled");
|
||||
});
|
||||
|
||||
it("should accept valid key: hpReactiveCamStylingEnabled", () => {
|
||||
expect(validateSettingKey("hpReactiveCamStylingEnabled")).toBe(
|
||||
"hpReactiveCamStylingEnabled"
|
||||
);
|
||||
});
|
||||
|
||||
it("should throw TypeError for empty string", () => {
|
||||
expect(() => validateSettingKey("")).toThrow(TypeError);
|
||||
expect(() => validateSettingKey("")).toThrow(
|
||||
@@ -332,12 +272,6 @@ describe("privacy-settings contract", () => {
|
||||
expect(validateFeatureName("reactionCam")).toBe("reactionCam");
|
||||
});
|
||||
|
||||
it("should accept valid feature: hpReactiveCamStyling", () => {
|
||||
expect(validateFeatureName("hpReactiveCamStyling")).toBe(
|
||||
"hpReactiveCamStyling"
|
||||
);
|
||||
});
|
||||
|
||||
it("should throw TypeError for empty string", () => {
|
||||
expect(() => validateFeatureName("")).toThrow(TypeError);
|
||||
expect(() => validateFeatureName("")).toThrow(
|
||||
@@ -399,7 +333,6 @@ describe("privacy-settings contract", () => {
|
||||
|
||||
it("should retain existing boolean settings", () => {
|
||||
expect(PRIVACY_SETTINGS_DEFAULT.reactionCamEnabled).toBe(false);
|
||||
expect(PRIVACY_SETTINGS_DEFAULT.hpReactiveCamStylingEnabled).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -410,7 +343,6 @@ describe("privacy-settings contract", () => {
|
||||
|
||||
it("should retain existing keys", () => {
|
||||
expect(PRIVACY_SETTING_KEYS).toContain("reactionCamEnabled");
|
||||
expect(PRIVACY_SETTING_KEYS).toContain("hpReactiveCamStylingEnabled");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -443,7 +375,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should accept valid settings with customPortraitFallback as string", () => {
|
||||
const valid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: "data:image/png;base64,test",
|
||||
};
|
||||
expect(isValidPrivacySettings(valid)).toEqual(valid);
|
||||
@@ -452,7 +383,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should accept valid settings with customPortraitFallback as null", () => {
|
||||
const valid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: null,
|
||||
};
|
||||
expect(isValidPrivacySettings(valid)).toEqual(valid);
|
||||
@@ -462,7 +392,6 @@ describe("privacy-settings contract", () => {
|
||||
// Backward compatibility - may not have the key
|
||||
const valid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
};
|
||||
// This should still work - null/undefined is acceptable
|
||||
expect(() => isValidPrivacySettings(valid)).not.toThrow();
|
||||
@@ -471,7 +400,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should throw TypeError when customPortraitFallback is not string or null", () => {
|
||||
const invalid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: 123,
|
||||
};
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(TypeError);
|
||||
@@ -483,7 +411,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should throw TypeError when customPortraitFallback is a boolean", () => {
|
||||
const invalid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: true,
|
||||
};
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(TypeError);
|
||||
@@ -495,7 +422,6 @@ describe("privacy-settings contract", () => {
|
||||
it("should throw TypeError when customPortraitFallback is an object", () => {
|
||||
const invalid = {
|
||||
reactionCamEnabled: false,
|
||||
hpReactiveCamStylingEnabled: false,
|
||||
customPortraitFallback: {},
|
||||
};
|
||||
expect(() => isValidPrivacySettings(invalid)).toThrow(TypeError);
|
||||
|
||||
Reference in New Issue
Block a user