Normalizers: fix tests
This commit is contained in:
parent
7a18f8b9c8
commit
10116a312a
4 changed files with 22 additions and 3 deletions
|
@ -11,6 +11,13 @@ const makeEmojiMap = record => record.emojis.reduce((obj, emoji) => {
|
|||
export function normalizeAccount(account) {
|
||||
account = { ...account };
|
||||
|
||||
// Some backends can return null, or omit these required fields
|
||||
if (!account.emojis) account.emojis = [];
|
||||
if (!account.display_name) account.display_name = '';
|
||||
if (!account.note) account.note = '';
|
||||
if (!account.avatar) account.avatar = account.avatar_static || require('images/avatar-missing.png');
|
||||
if (!account.avatar_static) account.avatar_static = account.avatar;
|
||||
|
||||
const emojiMap = makeEmojiMap(account);
|
||||
const displayName = account.display_name.trim().length === 0 ? account.username : account.display_name;
|
||||
|
||||
|
|
|
@ -32,7 +32,19 @@ describe('normalizeInstance()', () => {
|
|||
fedibird_capabilities: [],
|
||||
invites_enabled: false,
|
||||
languages: [],
|
||||
pleroma: {},
|
||||
pleroma: {
|
||||
metadata: {
|
||||
account_activation_required: false,
|
||||
birthday_min_age: 0,
|
||||
birthday_required: false,
|
||||
features: [],
|
||||
federation: {
|
||||
enabled: true,
|
||||
exclusions: false,
|
||||
},
|
||||
},
|
||||
stats: {},
|
||||
},
|
||||
registrations: false,
|
||||
rules: [],
|
||||
short_description: '',
|
||||
|
|
|
@ -8,6 +8,7 @@ const StatusRecord = Record({
|
|||
application: null,
|
||||
bookmarked: false,
|
||||
card: null,
|
||||
content: '',
|
||||
created_at: new Date(),
|
||||
emojis: ImmutableList(),
|
||||
favourited: false,
|
||||
|
|
|
@ -89,8 +89,7 @@ const fixQuote = (status, oldStatus) => {
|
|||
const fixStatus = (state, status, expandSpoilers) => {
|
||||
const oldStatus = state.get(status.get('id'));
|
||||
|
||||
return status.withMutations(status => {
|
||||
normalizeStatus(status);
|
||||
return normalizeStatus(status).withMutations(status => {
|
||||
fixQuote(status, oldStatus);
|
||||
calculateStatus(status, oldStatus, expandSpoilers);
|
||||
minifyStatus(status);
|
||||
|
|
Loading…
Reference in a new issue