prefer TypeScript for tests
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
e78108efe2
commit
7b5114a1b8
|
@ -10,7 +10,7 @@ describe('<AutosuggestEmoji />', () => {
|
|||
colons: ':foobar:',
|
||||
};
|
||||
|
||||
render(<AutosuggestEmoji emoji={emoji} />);
|
||||
render(<AutosuggestEmoji emoji={emoji as any} />);
|
||||
|
||||
expect(screen.getByTestId('emoji')).toHaveTextContent('foobar');
|
||||
expect(screen.getByRole('img').getAttribute('src')).not.toBe('http://example.com/emoji.png');
|
||||
|
@ -24,7 +24,7 @@ describe('<AutosuggestEmoji />', () => {
|
|||
colons: ':foobar:',
|
||||
};
|
||||
|
||||
render(<AutosuggestEmoji emoji={emoji} />);
|
||||
render(<AutosuggestEmoji emoji={emoji as any} />);
|
||||
|
||||
expect(screen.getByTestId('emoji')).toHaveTextContent('foobar');
|
||||
expect(screen.getByRole('img').getAttribute('src')).toBe('http://example.com/emoji.png');
|
|
@ -15,7 +15,7 @@ const getOrderedLists = createSelector([(state: RootState) => state.lists], list
|
|||
return lists;
|
||||
}
|
||||
|
||||
return lists.toList().filter(item => !!item).sort((a, b) => (a as ListEntity).title.localeCompare((b as ListEntity).title)).take(4) as ImmutableList<ListEntity>;;
|
||||
return lists.toList().filter(item => !!item).sort((a, b) => (a as ListEntity).title.localeCompare((b as ListEntity).title)).take(4) as ImmutableList<ListEntity>;
|
||||
});
|
||||
|
||||
const ListPanel = () => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
import { List as ImmutableList, Map as ImmutableMap, fromJS } from 'immutable';
|
||||
|
||||
import * as actions from 'soapbox/actions/compose';
|
||||
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
|
||||
|
@ -220,7 +220,7 @@ describe('compose reducer', () => {
|
|||
});
|
||||
|
||||
it('should handle COMPOSE_SPOILERNESS_CHANGE on CW button click', () => {
|
||||
const state = ImmutableMap({ spoiler_text: 'spoiler text', spoiler: true, media_attachments: { } });
|
||||
const state = ImmutableMap({ spoiler_text: 'spoiler text', spoiler: true, media_attachments: ImmutableList() });
|
||||
const action = {
|
||||
type: actions.COMPOSE_SPOILERNESS_CHANGE,
|
||||
};
|
||||
|
@ -337,7 +337,7 @@ describe('compose reducer', () => {
|
|||
});
|
||||
|
||||
it('should handle COMPOSE_UPLOAD_SUCCESS', () => {
|
||||
const state = ImmutableMap({ media_attachments: [] });
|
||||
const state = ImmutableMap({ media_attachments: ImmutableList() });
|
||||
const media = [
|
||||
{
|
||||
description: null,
|
||||
|
@ -385,19 +385,18 @@ describe('compose reducer', () => {
|
|||
});
|
||||
|
||||
it('should handle COMPOSE_SUGGESTIONS_CLEAR', () => {
|
||||
const state = ImmutableMap({ });
|
||||
const action = {
|
||||
type: actions.COMPOSE_SUGGESTIONS_CLEAR,
|
||||
suggestions: [],
|
||||
suggestion_token: 'aiekdns3',
|
||||
};
|
||||
expect(reducer(state, action).toJS()).toMatchObject({
|
||||
expect(reducer(undefined, action).toJS()).toMatchObject({
|
||||
suggestion_token: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle COMPOSE_SUGGESTION_TAGS_UPDATE', () => {
|
||||
const state = ImmutableMap({ tagHistory: [ 'hashtag' ] });
|
||||
const state = ImmutableMap({ tagHistory: ImmutableList([ 'hashtag' ]) });
|
||||
const action = {
|
||||
type: actions.COMPOSE_SUGGESTION_TAGS_UPDATE,
|
||||
token: 'aaadken3',
|
||||
|
@ -410,12 +409,11 @@ describe('compose reducer', () => {
|
|||
});
|
||||
|
||||
it('should handle COMPOSE_TAG_HISTORY_UPDATE', () => {
|
||||
const state = ImmutableMap({ });
|
||||
const action = {
|
||||
type: actions.COMPOSE_TAG_HISTORY_UPDATE,
|
||||
tags: [ 'hashtag', 'hashtag2'],
|
||||
};
|
||||
expect(reducer(state, action).toJS()).toMatchObject({
|
||||
expect(reducer(undefined, action).toJS()).toMatchObject({
|
||||
tagHistory: [ 'hashtag', 'hashtag2' ],
|
||||
});
|
||||
});
|
||||
|
@ -450,11 +448,10 @@ describe('compose reducer', () => {
|
|||
});
|
||||
|
||||
it('should handle COMPOSE_POLL_REMOVE', () => {
|
||||
const state = ImmutableMap({ });
|
||||
const action = {
|
||||
type: actions.COMPOSE_POLL_REMOVE,
|
||||
};
|
||||
expect(reducer(state, action).toJS()).toMatchObject({
|
||||
expect(reducer(undefined, action).toJS()).toMatchObject({
|
||||
poll: null,
|
||||
});
|
||||
});
|
|
@ -13,7 +13,7 @@ import reducer, { ReducerRecord } from '../contexts';
|
|||
|
||||
describe('contexts reducer', () => {
|
||||
it('should return the initial state', () => {
|
||||
expect(reducer(undefined, {})).toEqual(ReducerRecord({
|
||||
expect(reducer(undefined, {} as any)).toEqual(ReducerRecord({
|
||||
inReplyTos: ImmutableMap(),
|
||||
replies: ImmutableMap(),
|
||||
}));
|
||||
|
@ -97,18 +97,18 @@ describe('contexts reducer', () => {
|
|||
inReplyTos: fromJS({
|
||||
B: 'A',
|
||||
C: 'B',
|
||||
}),
|
||||
}) as ImmutableMap<string, string>,
|
||||
replies: fromJS({
|
||||
A: ImmutableOrderedSet(['B']),
|
||||
B: ImmutableOrderedSet(['C']),
|
||||
}),
|
||||
}) as ImmutableMap<string, ImmutableOrderedSet<string>>,
|
||||
});
|
||||
|
||||
const expected = ReducerRecord({
|
||||
inReplyTos: fromJS({}),
|
||||
inReplyTos: fromJS({}) as ImmutableMap<string, string>,
|
||||
replies: fromJS({
|
||||
A: ImmutableOrderedSet(),
|
||||
}),
|
||||
}) as ImmutableMap<string, ImmutableOrderedSet<string>>,
|
||||
});
|
||||
|
||||
expect(reducer(state, action)).toEqual(expected);
|
|
@ -6,7 +6,7 @@ import reducer from '../list_adder';
|
|||
|
||||
describe('list_adder reducer', () => {
|
||||
it('should return the initial state', () => {
|
||||
expect(reducer(undefined, {})).toMatchObject({
|
||||
expect(reducer(undefined, {} as any)).toMatchObject({
|
||||
accountId: null,
|
||||
|
||||
lists: {
|
||||
|
@ -22,7 +22,7 @@ describe('list_adder reducer', () => {
|
|||
accountId: null,
|
||||
|
||||
lists: ImmutableRecord({
|
||||
items: ImmutableList(),
|
||||
items: ImmutableList<string>(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
})(),
|
||||
|
@ -46,7 +46,7 @@ describe('list_adder reducer', () => {
|
|||
accountId: null,
|
||||
|
||||
lists: ImmutableRecord({
|
||||
items: ImmutableList(),
|
||||
items: ImmutableList<string>(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
})(),
|
||||
|
@ -70,7 +70,7 @@ describe('list_adder reducer', () => {
|
|||
accountId: null,
|
||||
|
||||
lists: ImmutableRecord({
|
||||
items: ImmutableList(),
|
||||
items: ImmutableList<string>(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
})(),
|
|
@ -1,4 +1,4 @@
|
|||
import { List as ImmutableList } from 'immutable';
|
||||
import { List as ImmutableList, Record as ImmutableRecord } from 'immutable';
|
||||
|
||||
import { MODAL_OPEN, MODAL_CLOSE } from 'soapbox/actions/modals';
|
||||
|
||||
|
@ -6,11 +6,11 @@ import reducer from '../modals';
|
|||
|
||||
describe('modal reducer', () => {
|
||||
it('should return the initial state', () => {
|
||||
expect(reducer(undefined, {})).toEqual(ImmutableList());
|
||||
expect(reducer(undefined, {} as any)).toEqual(ImmutableList());
|
||||
});
|
||||
|
||||
it('should handle MODAL_OPEN', () => {
|
||||
const state = ImmutableList();
|
||||
const state = ImmutableList<any>();
|
||||
const action = {
|
||||
type: MODAL_OPEN,
|
||||
modalType: 'type1',
|
||||
|
@ -23,35 +23,43 @@ describe('modal reducer', () => {
|
|||
});
|
||||
|
||||
it('should handle MODAL_CLOSE', () => {
|
||||
const state = ImmutableList([{
|
||||
modalType: 'type1',
|
||||
modalProps: { props1: '1' },
|
||||
}]);
|
||||
const state = ImmutableList([
|
||||
ImmutableRecord({
|
||||
modalType: 'type1',
|
||||
modalProps: { props1: '1' },
|
||||
})(),
|
||||
]);
|
||||
const action = {
|
||||
type: MODAL_CLOSE,
|
||||
};
|
||||
expect(reducer(state, action)).toMatchObject(ImmutableList());
|
||||
expect(reducer(state, action).toJS()).toMatchObject([]);
|
||||
});
|
||||
|
||||
it('should handle MODAL_CLOSE with specified modalType', () => {
|
||||
const state = ImmutableList([
|
||||
{
|
||||
ImmutableRecord({
|
||||
modalType: 'type1',
|
||||
},
|
||||
{
|
||||
modalProps: null,
|
||||
})(),
|
||||
ImmutableRecord({
|
||||
modalType: 'type2',
|
||||
},
|
||||
{
|
||||
modalProps: null,
|
||||
})(),
|
||||
ImmutableRecord({
|
||||
modalType: 'type1',
|
||||
},
|
||||
modalProps: null,
|
||||
})(),
|
||||
]);
|
||||
const action = {
|
||||
type: MODAL_CLOSE,
|
||||
modalType: 'type2',
|
||||
};
|
||||
expect(reducer(state, action)).toMatchObject(ImmutableList([{
|
||||
modalType: 'type1',
|
||||
}]));
|
||||
expect(reducer(state, action).toJS()).toEqual([
|
||||
{
|
||||
modalType: 'type1',
|
||||
modalProps: null,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
|
@ -42,6 +42,8 @@ describe('mutes reducer', () => {
|
|||
it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => {
|
||||
const state = ImmutableRecord({
|
||||
new: ImmutableRecord({
|
||||
isSubmitting: false,
|
||||
accountId: null,
|
||||
notifications: true,
|
||||
})(),
|
||||
})();
|
||||
|
@ -50,6 +52,8 @@ describe('mutes reducer', () => {
|
|||
};
|
||||
expect(reducer(state, action).toJS()).toEqual({
|
||||
new: {
|
||||
isSubmitting: false,
|
||||
accountId: null,
|
||||
notifications: false,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { fromJS } from 'immutable';
|
||||
import { List as ImmutableList, fromJS } from 'immutable';
|
||||
|
||||
import config_db from 'soapbox/__fixtures__/config_db.json';
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { ConfigDB } from '../config_db';
|
|||
|
||||
test('find', () => {
|
||||
const configs = fromJS(config_db).get('configs');
|
||||
expect(ConfigDB.find(configs, ':phoenix', ':json_library')).toEqual(fromJS({
|
||||
expect(ConfigDB.find(configs as ImmutableList<any>, ':phoenix', ':json_library')).toEqual(fromJS({
|
||||
group: ':phoenix',
|
||||
key: ':json_library',
|
||||
value: 'Jason',
|
Loading…
Reference in New Issue