2020-06-09 18:08:07 -07:00
|
|
|
import { Map as ImmutableMap } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-03-10 13:32:01 -08:00
|
|
|
import { POLLS_IMPORT } from 'soapbox/actions/importer';
|
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import reducer from '../polls';
|
2020-06-09 18:08:07 -07:00
|
|
|
|
|
|
|
describe('polls reducer', () => {
|
|
|
|
it('should return the initial state', () => {
|
|
|
|
expect(reducer(undefined, {})).toEqual(ImmutableMap());
|
|
|
|
});
|
2022-03-10 13:32:01 -08:00
|
|
|
|
|
|
|
describe('POLLS_IMPORT', () => {
|
|
|
|
it('normalizes the poll', () => {
|
|
|
|
const polls = [{ id: '3', options: [{ title: 'Apples' }] }];
|
|
|
|
const action = { type: POLLS_IMPORT, polls };
|
|
|
|
|
|
|
|
const result = reducer(undefined, action);
|
|
|
|
|
|
|
|
const expected = {
|
|
|
|
'3': {
|
|
|
|
options: [{ title: 'Apples', votes_count: 0 }],
|
|
|
|
emojis: [],
|
|
|
|
expired: false,
|
|
|
|
multiple: false,
|
|
|
|
voters_count: 0,
|
|
|
|
votes_count: 0,
|
2022-03-10 14:25:11 -08:00
|
|
|
own_votes: null,
|
2022-03-10 13:32:01 -08:00
|
|
|
voted: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(result.toJS()).toMatchObject(expected);
|
|
|
|
});
|
|
|
|
});
|
2020-06-09 18:08:07 -07:00
|
|
|
});
|