Fix mutes test, prefer TypeScript for tests

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-06-12 16:30:48 +02:00
parent cdbb88d2e0
commit 5fec879148
51 changed files with 49 additions and 39 deletions

View File

@ -47,8 +47,18 @@ const normalizeEmojis = (entity: ImmutableMap<string, any>) => {
});
};
const normalizePollOption = (option: ImmutableMap<string, any>, emojis: ImmutableList<ImmutableMap<string, string>> = ImmutableList()) => {
const normalizePollOption = (option: ImmutableMap<string, any> | string, emojis: ImmutableList<ImmutableMap<string, string>> = ImmutableList()) => {
const emojiMap = makeEmojiMap(emojis);
if (typeof option === 'string') {
const titleEmojified = emojify(escapeTextContentForBrowser(option), emojiMap);
return PollOptionRecord({
title: option,
title_emojified: titleEmojified,
});
}
const titleEmojified = emojify(escapeTextContentForBrowser(option.get('title')), emojiMap);
return PollOptionRecord(

View File

@ -6,7 +6,7 @@ import reducer from '../accounts';
describe('accounts reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap());
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
});
describe('ACCOUNT_IMPORT', () => {

View File

@ -9,7 +9,7 @@ import reducer from '../accounts_counters';
describe('accounts_counters reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap());
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
});
// it('should handle ACCOUNT_FOLLOW_SUCCESS', () => {

View File

@ -4,7 +4,7 @@ import reducer from '../admin';
describe('admin reducer', () => {
it('should return the initial state', () => {
const result = reducer(undefined, {});
const result = reducer(undefined, {} as any);
expect(ImmutableRecord.isRecord(result)).toBe(true);
expect(result.needsReboot).toBe(false);
});

View File

@ -4,6 +4,6 @@ import reducer from '../filters';
describe('filters reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableList());
expect(reducer(undefined, {} as any)).toEqual(ImmutableList());
});
});

View File

@ -7,7 +7,7 @@ import reducer from '../instance';
describe('instance reducer', () => {
it('should return the initial state', () => {
const result = reducer(undefined, {});
const result = reducer(undefined, {} as any);
const expected = {
description_limit: 1500,
@ -128,7 +128,7 @@ describe('instance reducer', () => {
};
// The normalizer has `registrations: closed` by default
const state = reducer(undefined, {});
const state = reducer(undefined, {} as any);
expect(state.registrations).toBe(false);
// After importing the configs, registration will be open

View File

@ -4,6 +4,6 @@ import reducer from '../lists';
describe('lists reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap());
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
});
});

View File

@ -2,6 +2,6 @@ import reducer from '../me';
describe('me reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(null);
expect(reducer(undefined, {} as any)).toEqual(null);
});
});

View File

@ -1,4 +1,4 @@
import { Map as ImmutableMap } from 'immutable';
import { Record as ImmutableRecord } from 'immutable';
import {
MUTES_INIT_MODAL,
@ -9,50 +9,50 @@ import reducer from '../mutes';
describe('mutes reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap({
new: ImmutableMap({
expect(reducer(undefined, {}).toJS()).toEqual({
new: {
isSubmitting: false,
account: null,
accountId: null,
notifications: true,
}),
}));
},
});
});
it('should handle MUTES_INIT_MODAL', () => {
const state = ImmutableMap({
new: ImmutableMap({
const state = ImmutableRecord({
new: ImmutableRecord({
isSubmitting: false,
account: null,
accountId: null,
notifications: true,
}),
});
})(),
})();
const action = {
type: MUTES_INIT_MODAL,
account: 'account1',
account: { id: 'account1' },
};
expect(reducer(state, action)).toEqual(ImmutableMap({
new: ImmutableMap({
expect(reducer(state, action).toJS()).toEqual({
new: {
isSubmitting: false,
account: 'account1',
accountId: 'account1',
notifications: true,
}),
}));
},
});
});
it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => {
const state = ImmutableMap({
new: ImmutableMap({
const state = ImmutableRecord({
new: ImmutableRecord({
notifications: true,
}),
});
})(),
})();
const action = {
type: MUTES_TOGGLE_HIDE_NOTIFICATIONS,
};
expect(reducer(state, action)).toEqual(ImmutableMap({
new: ImmutableMap({
expect(reducer(state, action).toJS()).toEqual({
new: {
notifications: false,
}),
}));
},
});
});
});

View File

@ -5,7 +5,7 @@ import reducer from '../patron';
describe('patron reducer', () => {
it('should return the initial state', () => {
const result = reducer(undefined, {});
const result = reducer(undefined, {} as any);
expect(ImmutableRecord.isRecord(result)).toBe(true);
expect(result.instance.url).toBe('');
});

View File

@ -6,7 +6,7 @@ import reducer from '../polls';
describe('polls reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap());
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
});
describe('POLLS_IMPORT', () => {

View File

@ -6,7 +6,7 @@ describe('push_notifications reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap({
subscription: null,
alerts: new ImmutableMap({
alerts: ImmutableMap({
follow: true,
follow_request: true,
favourite: true,

View File

@ -2,7 +2,7 @@ import reducer from '../reports';
describe('reports reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {}).toJS()).toEqual({
expect(reducer(undefined, {} as any).toJS()).toEqual({
new: {
isSubmitting: false,
account_id: null,

View File

@ -2,6 +2,6 @@ import reducer from '../sidebar';
describe('sidebar reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual({ sidebarOpen: false });
expect(reducer(undefined, {} as any)).toEqual({ sidebarOpen: false });
});
});