Merge branch 'to-test' into 'develop'

Compose: add mentions from text test

See merge request soapbox-pub/soapbox-fe!1684
react-query-api
Alex Gleason 2022-07-27 12:44:50 +00:00
commit 7d134fcca3
2 zmienionych plików z 27 dodań i 3 usunięć

Wyświetl plik

@ -1,9 +1,10 @@
import { Map as ImmutableMap } from 'immutable';
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
import { mockStore, rootState } from 'soapbox/jest/test-helpers';
import { InstanceRecord } from 'soapbox/normalizers';
import { uploadCompose } from '../compose';
import { uploadCompose, submitCompose } from '../compose';
import { STATUS_CREATE_REQUEST } from '../statuses';
import type { IntlShape } from 'react-intl';
@ -112,3 +113,26 @@ describe('uploadCompose()', () => {
});
});
});
describe('submitCompose()', () => {
it('inserts mentions from text', async() => {
const state = rootState
.set('me', '123')
.setIn(['compose', 'text'], '@alex hello @mkljczk@pl.fediverse.pl @gg@汉语/漢語.com alex@alexgleason.me');
const store = mockStore(state);
await store.dispatch(submitCompose());
const actions = store.getActions();
const statusCreateRequest = actions.find(action => action.type === STATUS_CREATE_REQUEST);
const to = statusCreateRequest!.params.to as ImmutableOrderedSet<string>;
const expected = [
'alex',
'mkljczk@pl.fediverse.pl',
'gg@汉语/漢語.com',
];
expect(to.toJS()).toEqual(expected);
});
});

Wyświetl plik

@ -229,7 +229,7 @@ const validateSchedule = (state: RootState) => {
return schedule.getTime() > fiveMinutesFromNow.getTime();
};
const submitCompose = (routerHistory: History, force = false) =>
const submitCompose = (routerHistory?: History, force = false) =>
(dispatch: AppDispatch, getState: () => RootState) => {
if (!isLoggedIn(getState)) return;
const state = getState();