kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Create Notification normalizer
rodzic
e5f1fae956
commit
37827c34d9
|
@ -0,0 +1,17 @@
|
|||
import { Record as ImmutableRecord, fromJS } from 'immutable';
|
||||
|
||||
import { normalizeNotification } from '../notification';
|
||||
|
||||
describe('normalizeNotification()', () => {
|
||||
it('normalizes an empty map', () => {
|
||||
const notification = fromJS({});
|
||||
const result = normalizeNotification(notification);
|
||||
|
||||
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
||||
expect(result.type).toEqual('');
|
||||
expect(result.account).toBe(null);
|
||||
expect(result.target).toBe(null);
|
||||
expect(result.status).toBe(null);
|
||||
expect(result.id).toEqual('');
|
||||
});
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
import {
|
||||
Map as ImmutableMap,
|
||||
Record as ImmutableRecord,
|
||||
} from 'immutable';
|
||||
|
||||
// https://docs.joinmastodon.org/entities/notification/
|
||||
const NotificationRecord = ImmutableRecord({
|
||||
account: null,
|
||||
chat_message: null, // pleroma:chat_mention
|
||||
created_at: new Date(),
|
||||
emoji: null, // pleroma:emoji_reaction
|
||||
id: '',
|
||||
status: null,
|
||||
target: null, // move
|
||||
type: '',
|
||||
});
|
||||
|
||||
export const normalizeNotification = (notification: ImmutableMap<string, any>) => {
|
||||
return NotificationRecord(notification);
|
||||
};
|
Ładowanie…
Reference in New Issue