mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
* fix: Stricter validation of team preferences * Omit unknown keys in presenters
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { NotificationEventType, UserPreference } from "@shared/types";
|
|
import { User } from "@server/models";
|
|
import presentUser from "./user";
|
|
|
|
it("presents a user", async () => {
|
|
const user = presentUser(
|
|
User.build({
|
|
id: "123",
|
|
name: "Test User",
|
|
})
|
|
);
|
|
expect(user).toMatchSnapshot();
|
|
});
|
|
|
|
it("presents a user without slack data", async () => {
|
|
const user = presentUser(
|
|
User.build({
|
|
id: "123",
|
|
name: "Test User",
|
|
})
|
|
);
|
|
expect(user).toMatchSnapshot();
|
|
});
|
|
|
|
it("omits unrecognized preferences and notification settings", async () => {
|
|
const user = User.build({ id: "123", name: "Test User" });
|
|
user.preferences = JSON.parse(
|
|
'{"seamlessEdit":true,"unknownPreference":true}'
|
|
);
|
|
user.notificationSettings = JSON.parse(
|
|
'{"documents.publish":true,"unknown.event":true}'
|
|
);
|
|
|
|
const data = presentUser(user, { includeDetails: true });
|
|
expect(data.preferences).toEqual({
|
|
[UserPreference.SeamlessEdit]: true,
|
|
});
|
|
expect(data.notificationSettings).toEqual({
|
|
[NotificationEventType.PublishDocument]: true,
|
|
});
|
|
});
|