Compose: add mentions from text test
This commit is contained in:
parent
a984bfd76a
commit
33f20564c7
|
@ -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 { mockStore, rootState } from 'soapbox/jest/test-helpers';
|
||||||
import { InstanceRecord } from 'soapbox/normalizers';
|
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';
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -229,7 +229,7 @@ const validateSchedule = (state: RootState) => {
|
||||||
return schedule.getTime() > fiveMinutesFromNow.getTime();
|
return schedule.getTime() > fiveMinutesFromNow.getTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitCompose = (routerHistory: History, force = false) =>
|
const submitCompose = (routerHistory?: History, force = false) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
if (!isLoggedIn(getState)) return;
|
if (!isLoggedIn(getState)) return;
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
|
Loading…
Reference in New Issue