mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 21:31:46 +00:00
fb36ae5678
The i18n and schema changes added code that wasn't prettier-formatted, and place.schema.ts imported categorySchema without using it. Run prettier over shared and remove the import so 'npm run lint' + 'format:check' pass.
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import {
|
|
preferencesUpdateRequestSchema,
|
|
notificationRespondRequestSchema,
|
|
channelTestResultSchema,
|
|
inAppListResultSchema,
|
|
} from './notification.schema';
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
describe('preferencesUpdateRequestSchema', () => {
|
|
it('accepts a nested event/channel/enabled matrix', () => {
|
|
expect(
|
|
preferencesUpdateRequestSchema.safeParse({
|
|
trip_invite: { inapp: true, email: false },
|
|
}).success,
|
|
).toBe(true);
|
|
expect(
|
|
preferencesUpdateRequestSchema.safeParse({
|
|
trip_invite: { inapp: 'yes' },
|
|
}).success,
|
|
).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('notificationRespondRequestSchema', () => {
|
|
it('only accepts positive/negative', () => {
|
|
expect(
|
|
notificationRespondRequestSchema.safeParse({ response: 'positive' })
|
|
.success,
|
|
).toBe(true);
|
|
expect(
|
|
notificationRespondRequestSchema.safeParse({ response: 'maybe' }).success,
|
|
).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('channelTestResultSchema', () => {
|
|
it('accepts a success result and an error result', () => {
|
|
expect(channelTestResultSchema.safeParse({ success: true }).success).toBe(
|
|
true,
|
|
);
|
|
expect(
|
|
channelTestResultSchema.safeParse({ success: false, error: 'SMTP down' })
|
|
.success,
|
|
).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('inAppListResultSchema', () => {
|
|
it('accepts the list envelope with open notification rows', () => {
|
|
expect(
|
|
inAppListResultSchema.safeParse({
|
|
notifications: [{ id: 1, type: 'info', anything: 'goes' }],
|
|
total: 1,
|
|
unread_count: 0,
|
|
}).success,
|
|
).toBe(true);
|
|
});
|
|
});
|