Fix mutes test, prefer TypeScript for tests
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
cdbb88d2e0
commit
5fec879148
|
@ -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);
|
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);
|
const titleEmojified = emojify(escapeTextContentForBrowser(option.get('title')), emojiMap);
|
||||||
|
|
||||||
return PollOptionRecord(
|
return PollOptionRecord(
|
||||||
|
|
|
@ -6,7 +6,7 @@ import reducer from '../accounts';
|
||||||
|
|
||||||
describe('accounts reducer', () => {
|
describe('accounts reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap());
|
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ACCOUNT_IMPORT', () => {
|
describe('ACCOUNT_IMPORT', () => {
|
|
@ -9,7 +9,7 @@ import reducer from '../accounts_counters';
|
||||||
|
|
||||||
describe('accounts_counters reducer', () => {
|
describe('accounts_counters reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap());
|
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('should handle ACCOUNT_FOLLOW_SUCCESS', () => {
|
// it('should handle ACCOUNT_FOLLOW_SUCCESS', () => {
|
|
@ -4,7 +4,7 @@ import reducer from '../admin';
|
||||||
|
|
||||||
describe('admin reducer', () => {
|
describe('admin reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
const result = reducer(undefined, {});
|
const result = reducer(undefined, {} as any);
|
||||||
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
||||||
expect(result.needsReboot).toBe(false);
|
expect(result.needsReboot).toBe(false);
|
||||||
});
|
});
|
|
@ -4,6 +4,6 @@ import reducer from '../filters';
|
||||||
|
|
||||||
describe('filters reducer', () => {
|
describe('filters reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableList());
|
expect(reducer(undefined, {} as any)).toEqual(ImmutableList());
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -7,7 +7,7 @@ import reducer from '../instance';
|
||||||
|
|
||||||
describe('instance reducer', () => {
|
describe('instance reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
const result = reducer(undefined, {});
|
const result = reducer(undefined, {} as any);
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
description_limit: 1500,
|
description_limit: 1500,
|
||||||
|
@ -128,7 +128,7 @@ describe('instance reducer', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// The normalizer has `registrations: closed` by default
|
// The normalizer has `registrations: closed` by default
|
||||||
const state = reducer(undefined, {});
|
const state = reducer(undefined, {} as any);
|
||||||
expect(state.registrations).toBe(false);
|
expect(state.registrations).toBe(false);
|
||||||
|
|
||||||
// After importing the configs, registration will be open
|
// After importing the configs, registration will be open
|
|
@ -4,6 +4,6 @@ import reducer from '../lists';
|
||||||
|
|
||||||
describe('lists reducer', () => {
|
describe('lists reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap());
|
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -2,6 +2,6 @@ import reducer from '../me';
|
||||||
|
|
||||||
describe('me reducer', () => {
|
describe('me reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(null);
|
expect(reducer(undefined, {} as any)).toEqual(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -1,4 +1,4 @@
|
||||||
import { Map as ImmutableMap } from 'immutable';
|
import { Record as ImmutableRecord } from 'immutable';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MUTES_INIT_MODAL,
|
MUTES_INIT_MODAL,
|
||||||
|
@ -9,50 +9,50 @@ import reducer from '../mutes';
|
||||||
|
|
||||||
describe('mutes reducer', () => {
|
describe('mutes reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
expect(reducer(undefined, {}).toJS()).toEqual({
|
||||||
new: ImmutableMap({
|
new: {
|
||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
account: null,
|
accountId: null,
|
||||||
notifications: true,
|
notifications: true,
|
||||||
}),
|
},
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle MUTES_INIT_MODAL', () => {
|
it('should handle MUTES_INIT_MODAL', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableRecord({
|
||||||
new: ImmutableMap({
|
new: ImmutableRecord({
|
||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
account: null,
|
accountId: null,
|
||||||
notifications: true,
|
notifications: true,
|
||||||
}),
|
})(),
|
||||||
});
|
})();
|
||||||
const action = {
|
const action = {
|
||||||
type: MUTES_INIT_MODAL,
|
type: MUTES_INIT_MODAL,
|
||||||
account: 'account1',
|
account: { id: 'account1' },
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action).toJS()).toEqual({
|
||||||
new: ImmutableMap({
|
new: {
|
||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
account: 'account1',
|
accountId: 'account1',
|
||||||
notifications: true,
|
notifications: true,
|
||||||
}),
|
},
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => {
|
it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableRecord({
|
||||||
new: ImmutableMap({
|
new: ImmutableRecord({
|
||||||
notifications: true,
|
notifications: true,
|
||||||
}),
|
})(),
|
||||||
});
|
})();
|
||||||
const action = {
|
const action = {
|
||||||
type: MUTES_TOGGLE_HIDE_NOTIFICATIONS,
|
type: MUTES_TOGGLE_HIDE_NOTIFICATIONS,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
expect(reducer(state, action).toJS()).toEqual({
|
||||||
new: ImmutableMap({
|
new: {
|
||||||
notifications: false,
|
notifications: false,
|
||||||
}),
|
},
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -5,7 +5,7 @@ import reducer from '../patron';
|
||||||
|
|
||||||
describe('patron reducer', () => {
|
describe('patron reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
const result = reducer(undefined, {});
|
const result = reducer(undefined, {} as any);
|
||||||
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
||||||
expect(result.instance.url).toBe('');
|
expect(result.instance.url).toBe('');
|
||||||
});
|
});
|
|
@ -6,7 +6,7 @@ import reducer from '../polls';
|
||||||
|
|
||||||
describe('polls reducer', () => {
|
describe('polls reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap());
|
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('POLLS_IMPORT', () => {
|
describe('POLLS_IMPORT', () => {
|
|
@ -6,7 +6,7 @@ describe('push_notifications reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
||||||
subscription: null,
|
subscription: null,
|
||||||
alerts: new ImmutableMap({
|
alerts: ImmutableMap({
|
||||||
follow: true,
|
follow: true,
|
||||||
follow_request: true,
|
follow_request: true,
|
||||||
favourite: true,
|
favourite: true,
|
|
@ -2,7 +2,7 @@ import reducer from '../reports';
|
||||||
|
|
||||||
describe('reports reducer', () => {
|
describe('reports reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {}).toJS()).toEqual({
|
expect(reducer(undefined, {} as any).toJS()).toEqual({
|
||||||
new: {
|
new: {
|
||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
account_id: null,
|
account_id: null,
|
|
@ -2,6 +2,6 @@ import reducer from '../sidebar';
|
||||||
|
|
||||||
describe('sidebar reducer', () => {
|
describe('sidebar reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual({ sidebarOpen: false });
|
expect(reducer(undefined, {} as any)).toEqual({ sidebarOpen: false });
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue