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:',
|
colons: ':foobar:',
|
||||||
};
|
};
|
||||||
|
|
||||||
render(<AutosuggestEmoji emoji={emoji} />);
|
render(<AutosuggestEmoji emoji={emoji as any} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('emoji')).toHaveTextContent('foobar');
|
expect(screen.getByTestId('emoji')).toHaveTextContent('foobar');
|
||||||
expect(screen.getByRole('img').getAttribute('src')).not.toBe('http://example.com/emoji.png');
|
expect(screen.getByRole('img').getAttribute('src')).not.toBe('http://example.com/emoji.png');
|
||||||
|
@ -24,7 +24,7 @@ describe('<AutosuggestEmoji />', () => {
|
||||||
colons: ':foobar:',
|
colons: ':foobar:',
|
||||||
};
|
};
|
||||||
|
|
||||||
render(<AutosuggestEmoji emoji={emoji} />);
|
render(<AutosuggestEmoji emoji={emoji as any} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('emoji')).toHaveTextContent('foobar');
|
expect(screen.getByTestId('emoji')).toHaveTextContent('foobar');
|
||||||
expect(screen.getByRole('img').getAttribute('src')).toBe('http://example.com/emoji.png');
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = () => {
|
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 * as actions from 'soapbox/actions/compose';
|
||||||
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
|
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', () => {
|
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 = {
|
const action = {
|
||||||
type: actions.COMPOSE_SPOILERNESS_CHANGE,
|
type: actions.COMPOSE_SPOILERNESS_CHANGE,
|
||||||
};
|
};
|
||||||
|
@ -337,7 +337,7 @@ describe('compose reducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle COMPOSE_UPLOAD_SUCCESS', () => {
|
it('should handle COMPOSE_UPLOAD_SUCCESS', () => {
|
||||||
const state = ImmutableMap({ media_attachments: [] });
|
const state = ImmutableMap({ media_attachments: ImmutableList() });
|
||||||
const media = [
|
const media = [
|
||||||
{
|
{
|
||||||
description: null,
|
description: null,
|
||||||
|
@ -385,19 +385,18 @@ describe('compose reducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle COMPOSE_SUGGESTIONS_CLEAR', () => {
|
it('should handle COMPOSE_SUGGESTIONS_CLEAR', () => {
|
||||||
const state = ImmutableMap({ });
|
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.COMPOSE_SUGGESTIONS_CLEAR,
|
type: actions.COMPOSE_SUGGESTIONS_CLEAR,
|
||||||
suggestions: [],
|
suggestions: [],
|
||||||
suggestion_token: 'aiekdns3',
|
suggestion_token: 'aiekdns3',
|
||||||
};
|
};
|
||||||
expect(reducer(state, action).toJS()).toMatchObject({
|
expect(reducer(undefined, action).toJS()).toMatchObject({
|
||||||
suggestion_token: null,
|
suggestion_token: null,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle COMPOSE_SUGGESTION_TAGS_UPDATE', () => {
|
it('should handle COMPOSE_SUGGESTION_TAGS_UPDATE', () => {
|
||||||
const state = ImmutableMap({ tagHistory: [ 'hashtag' ] });
|
const state = ImmutableMap({ tagHistory: ImmutableList([ 'hashtag' ]) });
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.COMPOSE_SUGGESTION_TAGS_UPDATE,
|
type: actions.COMPOSE_SUGGESTION_TAGS_UPDATE,
|
||||||
token: 'aaadken3',
|
token: 'aaadken3',
|
||||||
|
@ -410,12 +409,11 @@ describe('compose reducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle COMPOSE_TAG_HISTORY_UPDATE', () => {
|
it('should handle COMPOSE_TAG_HISTORY_UPDATE', () => {
|
||||||
const state = ImmutableMap({ });
|
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.COMPOSE_TAG_HISTORY_UPDATE,
|
type: actions.COMPOSE_TAG_HISTORY_UPDATE,
|
||||||
tags: [ 'hashtag', 'hashtag2'],
|
tags: [ 'hashtag', 'hashtag2'],
|
||||||
};
|
};
|
||||||
expect(reducer(state, action).toJS()).toMatchObject({
|
expect(reducer(undefined, action).toJS()).toMatchObject({
|
||||||
tagHistory: [ 'hashtag', 'hashtag2' ],
|
tagHistory: [ 'hashtag', 'hashtag2' ],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -450,11 +448,10 @@ describe('compose reducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle COMPOSE_POLL_REMOVE', () => {
|
it('should handle COMPOSE_POLL_REMOVE', () => {
|
||||||
const state = ImmutableMap({ });
|
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.COMPOSE_POLL_REMOVE,
|
type: actions.COMPOSE_POLL_REMOVE,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action).toJS()).toMatchObject({
|
expect(reducer(undefined, action).toJS()).toMatchObject({
|
||||||
poll: null,
|
poll: null,
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -13,7 +13,7 @@ import reducer, { ReducerRecord } from '../contexts';
|
||||||
|
|
||||||
describe('contexts reducer', () => {
|
describe('contexts reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ReducerRecord({
|
expect(reducer(undefined, {} as any)).toEqual(ReducerRecord({
|
||||||
inReplyTos: ImmutableMap(),
|
inReplyTos: ImmutableMap(),
|
||||||
replies: ImmutableMap(),
|
replies: ImmutableMap(),
|
||||||
}));
|
}));
|
||||||
|
@ -97,18 +97,18 @@ describe('contexts reducer', () => {
|
||||||
inReplyTos: fromJS({
|
inReplyTos: fromJS({
|
||||||
B: 'A',
|
B: 'A',
|
||||||
C: 'B',
|
C: 'B',
|
||||||
}),
|
}) as ImmutableMap<string, string>,
|
||||||
replies: fromJS({
|
replies: fromJS({
|
||||||
A: ImmutableOrderedSet(['B']),
|
A: ImmutableOrderedSet(['B']),
|
||||||
B: ImmutableOrderedSet(['C']),
|
B: ImmutableOrderedSet(['C']),
|
||||||
}),
|
}) as ImmutableMap<string, ImmutableOrderedSet<string>>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const expected = ReducerRecord({
|
const expected = ReducerRecord({
|
||||||
inReplyTos: fromJS({}),
|
inReplyTos: fromJS({}) as ImmutableMap<string, string>,
|
||||||
replies: fromJS({
|
replies: fromJS({
|
||||||
A: ImmutableOrderedSet(),
|
A: ImmutableOrderedSet(),
|
||||||
}),
|
}) as ImmutableMap<string, ImmutableOrderedSet<string>>,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reducer(state, action)).toEqual(expected);
|
expect(reducer(state, action)).toEqual(expected);
|
|
@ -6,7 +6,7 @@ import reducer from '../list_adder';
|
||||||
|
|
||||||
describe('list_adder reducer', () => {
|
describe('list_adder reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toMatchObject({
|
expect(reducer(undefined, {} as any)).toMatchObject({
|
||||||
accountId: null,
|
accountId: null,
|
||||||
|
|
||||||
lists: {
|
lists: {
|
||||||
|
@ -22,7 +22,7 @@ describe('list_adder reducer', () => {
|
||||||
accountId: null,
|
accountId: null,
|
||||||
|
|
||||||
lists: ImmutableRecord({
|
lists: ImmutableRecord({
|
||||||
items: ImmutableList(),
|
items: ImmutableList<string>(),
|
||||||
loaded: false,
|
loaded: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
})(),
|
})(),
|
||||||
|
@ -46,7 +46,7 @@ describe('list_adder reducer', () => {
|
||||||
accountId: null,
|
accountId: null,
|
||||||
|
|
||||||
lists: ImmutableRecord({
|
lists: ImmutableRecord({
|
||||||
items: ImmutableList(),
|
items: ImmutableList<string>(),
|
||||||
loaded: false,
|
loaded: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
})(),
|
})(),
|
||||||
|
@ -70,7 +70,7 @@ describe('list_adder reducer', () => {
|
||||||
accountId: null,
|
accountId: null,
|
||||||
|
|
||||||
lists: ImmutableRecord({
|
lists: ImmutableRecord({
|
||||||
items: ImmutableList(),
|
items: ImmutableList<string>(),
|
||||||
loaded: false,
|
loaded: false,
|
||||||
isLoading: 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';
|
import { MODAL_OPEN, MODAL_CLOSE } from 'soapbox/actions/modals';
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ import reducer from '../modals';
|
||||||
|
|
||||||
describe('modal reducer', () => {
|
describe('modal 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());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle MODAL_OPEN', () => {
|
it('should handle MODAL_OPEN', () => {
|
||||||
const state = ImmutableList();
|
const state = ImmutableList<any>();
|
||||||
const action = {
|
const action = {
|
||||||
type: MODAL_OPEN,
|
type: MODAL_OPEN,
|
||||||
modalType: 'type1',
|
modalType: 'type1',
|
||||||
|
@ -23,35 +23,43 @@ describe('modal reducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle MODAL_CLOSE', () => {
|
it('should handle MODAL_CLOSE', () => {
|
||||||
const state = ImmutableList([{
|
const state = ImmutableList([
|
||||||
modalType: 'type1',
|
ImmutableRecord({
|
||||||
modalProps: { props1: '1' },
|
modalType: 'type1',
|
||||||
}]);
|
modalProps: { props1: '1' },
|
||||||
|
})(),
|
||||||
|
]);
|
||||||
const action = {
|
const action = {
|
||||||
type: MODAL_CLOSE,
|
type: MODAL_CLOSE,
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toMatchObject(ImmutableList());
|
expect(reducer(state, action).toJS()).toMatchObject([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle MODAL_CLOSE with specified modalType', () => {
|
it('should handle MODAL_CLOSE with specified modalType', () => {
|
||||||
const state = ImmutableList([
|
const state = ImmutableList([
|
||||||
{
|
ImmutableRecord({
|
||||||
modalType: 'type1',
|
modalType: 'type1',
|
||||||
},
|
modalProps: null,
|
||||||
{
|
})(),
|
||||||
|
ImmutableRecord({
|
||||||
modalType: 'type2',
|
modalType: 'type2',
|
||||||
},
|
modalProps: null,
|
||||||
{
|
})(),
|
||||||
|
ImmutableRecord({
|
||||||
modalType: 'type1',
|
modalType: 'type1',
|
||||||
},
|
modalProps: null,
|
||||||
|
})(),
|
||||||
]);
|
]);
|
||||||
const action = {
|
const action = {
|
||||||
type: MODAL_CLOSE,
|
type: MODAL_CLOSE,
|
||||||
modalType: 'type2',
|
modalType: 'type2',
|
||||||
};
|
};
|
||||||
expect(reducer(state, action)).toMatchObject(ImmutableList([{
|
expect(reducer(state, action).toJS()).toEqual([
|
||||||
modalType: 'type1',
|
{
|
||||||
}]));
|
modalType: 'type1',
|
||||||
|
modalProps: null,
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -42,6 +42,8 @@ describe('mutes reducer', () => {
|
||||||
it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => {
|
it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => {
|
||||||
const state = ImmutableRecord({
|
const state = ImmutableRecord({
|
||||||
new: ImmutableRecord({
|
new: ImmutableRecord({
|
||||||
|
isSubmitting: false,
|
||||||
|
accountId: null,
|
||||||
notifications: true,
|
notifications: true,
|
||||||
})(),
|
})(),
|
||||||
})();
|
})();
|
||||||
|
@ -50,6 +52,8 @@ describe('mutes reducer', () => {
|
||||||
};
|
};
|
||||||
expect(reducer(state, action).toJS()).toEqual({
|
expect(reducer(state, action).toJS()).toEqual({
|
||||||
new: {
|
new: {
|
||||||
|
isSubmitting: false,
|
||||||
|
accountId: null,
|
||||||
notifications: false,
|
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';
|
import config_db from 'soapbox/__fixtures__/config_db.json';
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { ConfigDB } from '../config_db';
|
||||||
|
|
||||||
test('find', () => {
|
test('find', () => {
|
||||||
const configs = fromJS(config_db).get('configs');
|
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',
|
group: ':phoenix',
|
||||||
key: ':json_library',
|
key: ':json_library',
|
||||||
value: 'Jason',
|
value: 'Jason',
|
Loading…
Reference in New Issue