started editing additional reducer tests

tl-language-filters
crockwave 2020-07-05 19:38:32 -05:00
rodzic f7f2b500b5
commit ca2ccb8a3c
4 zmienionych plików z 485 dodań i 127 usunięć

Wyświetl plik

@ -1,8 +1,297 @@
import reducer from '../accounts'; import reducer from '../accounts';
import { Map as ImmutableMap } from 'immutable'; import { Map as ImmutableMap } from 'immutable';
import * as actions from 'soapbox/actions/accounts';
describe('accounts reducer', () => { describe('accounts reducer', () => {
it('should return the initial state', () => { it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap()); expect(reducer(undefined, {})).toEqual(ImmutableMap());
}); });
it('should handle ACCOUNT_IMPORT', () => {
const state = ImmutableMap({ });
const account = {
'9w1HhmenIAKBHJiUs4': {
header_static: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png',
display_name_html: 'Alex Gleason',
bot: false,
display_name: 'Alex Gleason',
created_at: '2020-06-12T21:47:28.000Z',
locked: false,
emojis: [],
header: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png',
url: 'https://gleasonator.com/users/alex',
note: 'Fediverse developer. I come in peace. <a class="hashtag" data-tag="vegan" href="https://gleasonator.com/tag/vegan">#vegan</a> <a class="hashtag" data-tag="freeculture" href="https://gleasonator.com/tag/freeculture">#freeculture</a> <a class="hashtag" data-tag="atheist" href="https://gleasonator.com/tag/atheist">#atheist</a> <a class="hashtag" data-tag="antiporn" href="https://gleasonator.com/tag/antiporn">#antiporn</a> <a class="hashtag" data-tag="gendercritical" href="https://gleasonator.com/tag/gendercritical">#gendercritical</a>. Boosts ≠ endorsements.',
acct: 'alex@gleasonator.com',
avatar_static: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg',
username: 'alex',
avatar: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg',
fields: [
{
name: 'Website',
value: '<a href="https://alexgleason.me" rel="ugc">https://alexgleason.me</a>',
name_emojified: 'Website',
value_emojified: '<a href="https://alexgleason.me" rel="ugc">https://alexgleason.me</a>',
value_plain: 'https://alexgleason.me'
},
{
name: 'Pleroma+Soapbox',
value: '<a href="https://soapbox.pub" rel="ugc">https://soapbox.pub</a>',
name_emojified: 'Pleroma+Soapbox',
value_emojified: '<a href="https://soapbox.pub" rel="ugc">https://soapbox.pub</a>',
value_plain: 'https://soapbox.pub'
},
{
name: 'Email',
value: 'alex@alexgleason.me',
name_emojified: 'Email',
value_emojified: 'alex@alexgleason.me',
value_plain: 'alex@alexgleason.me'
},
{
name: 'Gender identity',
value: 'Soyboy',
name_emojified: 'Gender identity',
value_emojified: 'Soyboy',
value_plain: 'Soyboy'
}
],
pleroma: {
hide_follows: false,
hide_followers_count: false,
background_image: null,
confirmation_pending: false,
is_moderator: false,
hide_follows_count: false,
hide_followers: false,
relationship: {
showing_reblogs: true,
followed_by: false,
subscribing: false,
blocked_by: false,
requested: false,
domain_blocking: false,
following: false,
endorsed: false,
blocking: false,
muting: false,
id: '9w1HhmenIAKBHJiUs4',
muting_notifications: false
},
tags: [],
hide_favorites: true,
is_admin: false,
skip_thread_containment: false
},
source: {
fields: [],
note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.',
pleroma: {
actor_type: 'Person',
discoverable: false
},
sensitive: false
},
id: '9w1HhmenIAKBHJiUs4',
note_emojified: 'Fediverse developer. I come in peace. <a class="hashtag" data-tag="vegan" href="https://gleasonator.com/tag/vegan">#vegan</a> <a class="hashtag" data-tag="freeculture" href="https://gleasonator.com/tag/freeculture">#freeculture</a> <a class="hashtag" data-tag="atheist" href="https://gleasonator.com/tag/atheist">#atheist</a> <a class="hashtag" data-tag="antiporn" href="https://gleasonator.com/tag/antiporn">#antiporn</a> <a class="hashtag" data-tag="gendercritical" href="https://gleasonator.com/tag/gendercritical">#gendercritical</a>. Boosts ≠ endorsements.'
}
};
const action = {
type: actions.ACCOUNT_IMPORT,
account: account,
};
expect(reducer(state, action).toJS()).toMatchObject({
});
});
it('should handle ACCOUNTS_IMPORT', () => {
const state = ImmutableMap({ });
const accounts = {
'9w1HhmenIAKBHJiUs4': {
header_static: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png',
display_name_html: 'Alex Gleason',
bot: false,
display_name: 'Alex Gleason',
created_at: '2020-06-12T21:47:28.000Z',
locked: false,
emojis: [],
header: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png',
url: 'https://gleasonator.com/users/alex',
note: 'Fediverse developer. I come in peace. <a class="hashtag" data-tag="vegan" href="https://gleasonator.com/tag/vegan">#vegan</a> <a class="hashtag" data-tag="freeculture" href="https://gleasonator.com/tag/freeculture">#freeculture</a> <a class="hashtag" data-tag="atheist" href="https://gleasonator.com/tag/atheist">#atheist</a> <a class="hashtag" data-tag="antiporn" href="https://gleasonator.com/tag/antiporn">#antiporn</a> <a class="hashtag" data-tag="gendercritical" href="https://gleasonator.com/tag/gendercritical">#gendercritical</a>. Boosts ≠ endorsements.',
acct: 'alex@gleasonator.com',
avatar_static: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg',
username: 'alex',
avatar: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg',
fields: [
{
name: 'Website',
value: '<a href="https://alexgleason.me" rel="ugc">https://alexgleason.me</a>',
name_emojified: 'Website',
value_emojified: '<a href="https://alexgleason.me" rel="ugc">https://alexgleason.me</a>',
value_plain: 'https://alexgleason.me'
},
{
name: 'Pleroma+Soapbox',
value: '<a href="https://soapbox.pub" rel="ugc">https://soapbox.pub</a>',
name_emojified: 'Pleroma+Soapbox',
value_emojified: '<a href="https://soapbox.pub" rel="ugc">https://soapbox.pub</a>',
value_plain: 'https://soapbox.pub'
},
{
name: 'Email',
value: 'alex@alexgleason.me',
name_emojified: 'Email',
value_emojified: 'alex@alexgleason.me',
value_plain: 'alex@alexgleason.me'
},
{
name: 'Gender identity',
value: 'Soyboy',
name_emojified: 'Gender identity',
value_emojified: 'Soyboy',
value_plain: 'Soyboy'
}
],
pleroma: {
hide_follows: false,
hide_followers_count: false,
background_image: null,
confirmation_pending: false,
is_moderator: false,
hide_follows_count: false,
hide_followers: false,
relationship: {
showing_reblogs: true,
followed_by: false,
subscribing: false,
blocked_by: false,
requested: false,
domain_blocking: false,
following: false,
endorsed: false,
blocking: false,
muting: false,
id: '9w1HhmenIAKBHJiUs4',
muting_notifications: false
},
tags: [],
hide_favorites: true,
is_admin: false,
skip_thread_containment: false
},
source: {
fields: [],
note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.',
pleroma: {
actor_type: 'Person',
discoverable: false
},
sensitive: false
},
id: '9w1HhmenIAKBHJiUs4',
note_emojified: 'Fediverse developer. I come in peace. <a class="hashtag" data-tag="vegan" href="https://gleasonator.com/tag/vegan">#vegan</a> <a class="hashtag" data-tag="freeculture" href="https://gleasonator.com/tag/freeculture">#freeculture</a> <a class="hashtag" data-tag="atheist" href="https://gleasonator.com/tag/atheist">#atheist</a> <a class="hashtag" data-tag="antiporn" href="https://gleasonator.com/tag/antiporn">#antiporn</a> <a class="hashtag" data-tag="gendercritical" href="https://gleasonator.com/tag/gendercritical">#gendercritical</a>. Boosts ≠ endorsements.'
},
'9w1HhmenIAKBHJiUs4': {
header_static: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png',
display_name_html: 'Alex Gleason',
bot: false,
display_name: 'Alex Gleason',
created_at: '2020-06-12T21:47:28.000Z',
locked: false,
emojis: [],
header: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png',
url: 'https://gleasonator.com/users/alex',
note: 'Fediverse developer. I come in peace. <a class="hashtag" data-tag="vegan" href="https://gleasonator.com/tag/vegan">#vegan</a> <a class="hashtag" data-tag="freeculture" href="https://gleasonator.com/tag/freeculture">#freeculture</a> <a class="hashtag" data-tag="atheist" href="https://gleasonator.com/tag/atheist">#atheist</a> <a class="hashtag" data-tag="antiporn" href="https://gleasonator.com/tag/antiporn">#antiporn</a> <a class="hashtag" data-tag="gendercritical" href="https://gleasonator.com/tag/gendercritical">#gendercritical</a>. Boosts ≠ endorsements.',
acct: 'alex@gleasonator.com',
avatar_static: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg',
username: 'alex',
avatar: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg',
fields: [
{
name: 'Website',
value: '<a href="https://alexgleason.me" rel="ugc">https://alexgleason.me</a>',
name_emojified: 'Website',
value_emojified: '<a href="https://alexgleason.me" rel="ugc">https://alexgleason.me</a>',
value_plain: 'https://alexgleason.me'
},
{
name: 'Pleroma+Soapbox',
value: '<a href="https://soapbox.pub" rel="ugc">https://soapbox.pub</a>',
name_emojified: 'Pleroma+Soapbox',
value_emojified: '<a href="https://soapbox.pub" rel="ugc">https://soapbox.pub</a>',
value_plain: 'https://soapbox.pub'
},
{
name: 'Email',
value: 'alex@alexgleason.me',
name_emojified: 'Email',
value_emojified: 'alex@alexgleason.me',
value_plain: 'alex@alexgleason.me'
},
{
name: 'Gender identity',
value: 'Soyboy',
name_emojified: 'Gender identity',
value_emojified: 'Soyboy',
value_plain: 'Soyboy'
}
],
pleroma: {
hide_follows: false,
hide_followers_count: false,
background_image: null,
confirmation_pending: false,
is_moderator: false,
hide_follows_count: false,
hide_followers: false,
relationship: {
showing_reblogs: true,
followed_by: false,
subscribing: false,
blocked_by: false,
requested: false,
domain_blocking: false,
following: false,
endorsed: false,
blocking: false,
muting: false,
id: '9w1HhmenIAKBHJiUs4',
muting_notifications: false
},
tags: [],
hide_favorites: true,
is_admin: false,
skip_thread_containment: false
},
source: {
fields: [],
note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.',
pleroma: {
actor_type: 'Person',
discoverable: false
},
sensitive: false
},
id: '9w1HhmenIAKBHJiUs4',
note_emojified: 'Fediverse developer. I come in peace. <a class="hashtag" data-tag="vegan" href="https://gleasonator.com/tag/vegan">#vegan</a> <a class="hashtag" data-tag="freeculture" href="https://gleasonator.com/tag/freeculture">#freeculture</a> <a class="hashtag" data-tag="atheist" href="https://gleasonator.com/tag/atheist">#atheist</a> <a class="hashtag" data-tag="antiporn" href="https://gleasonator.com/tag/antiporn">#antiporn</a> <a class="hashtag" data-tag="gendercritical" href="https://gleasonator.com/tag/gendercritical">#gendercritical</a>. Boosts ≠ endorsements.'
}
};
const action = {
type: actions.ACCOUNTS_IMPORT,
accounts: accounts,
};
expect(reducer(state, action).toJS()).toMatchObject({
});
});
it('should handle ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP', () => {
const state = ImmutableMap({ username: 'curtis' });
const action = {
type: actions.ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP,
username: 'curtis',
};
expect(reducer(state, action).toJS()).toMatchObject({
username: 'curtis',
});
});
}); });

Wyświetl plik

@ -1,8 +1,43 @@
import reducer from '../alerts'; import reducer from '../alerts';
import { List as ImmutableList } from 'immutable'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import * as actions from '../alerts';
describe('alerts reducer', () => { describe('alerts reducer', () => {
it('should return the initial state', () => { it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableList()); expect(reducer(undefined, {})).toEqual(ImmutableList());
}); });
it('should handle ALERT_SHOW', () => {
const state = ImmutableMap({ key: 2 });
const action = {
type: actions.ALERT_SHOW,
title: 'alert_title',
message: 'this is an alert message',
};
expect(reducer(state, action).toJS()).toMatchObject({
key: 2,
});
});
it('should handle ALERT_DISMISS', () => {
const state = ImmutableMap({ key: 2 });
const action = {
type: actions.ALERT_DISMISS,
key: 2,
};
expect(reducer(state, action).toJS()).toMatchObject({
key: 2,
});
});
it('should handle ALERT_CLEAR', () => {
const state = ImmutableMap({ });
const action = {
type: actions.ALERT_CLEAR,
key: 2,
};
expect(reducer(state, action).toJS()).toMatchObject({
});
});
}); });

Wyświetl plik

@ -1,5 +1,6 @@
import reducer from '../auth'; import reducer from '../auth';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import * as actions from '../auth';
describe('auth reducer', () => { describe('auth reducer', () => {
it('should return the initial state', () => { it('should return the initial state', () => {
@ -9,4 +10,15 @@ describe('auth reducer', () => {
tokens: ImmutableList(), tokens: ImmutableList(),
})); }));
}); });
it('should handle AUTH_APP_CREATED', () => {
const state = ImmutableMap({ });
const action = {
type: actions.AUTH_APP_CREATED,
app: 'soapbox',
};
expect(reducer(state, action).toJS()).toMatchObject({
});
});
}); });

Wyświetl plik

@ -458,7 +458,7 @@ describe('compose reducer', () => {
// }, // },
// id: '9w1HhmenIAKBHJiUs4', // id: '9w1HhmenIAKBHJiUs4',
// note_emojified: 'Fediverse developer. I come in peace. <a class="hashtag" data-tag="vegan" href="https://gleasonator.com/tag/vegan">#vegan</a> <a class="hashtag" data-tag="freeculture" href="https://gleasonator.com/tag/freeculture">#freeculture</a> <a class="hashtag" data-tag="atheist" href="https://gleasonator.com/tag/atheist">#atheist</a> <a class="hashtag" data-tag="antiporn" href="https://gleasonator.com/tag/antiporn">#antiporn</a> <a class="hashtag" data-tag="gendercritical" href="https://gleasonator.com/tag/gendercritical">#gendercritical</a>. Boosts ≠ endorsements.' // note_emojified: 'Fediverse developer. I come in peace. <a class="hashtag" data-tag="vegan" href="https://gleasonator.com/tag/vegan">#vegan</a> <a class="hashtag" data-tag="freeculture" href="https://gleasonator.com/tag/freeculture">#freeculture</a> <a class="hashtag" data-tag="atheist" href="https://gleasonator.com/tag/atheist">#atheist</a> <a class="hashtag" data-tag="antiporn" href="https://gleasonator.com/tag/antiporn">#antiporn</a> <a class="hashtag" data-tag="gendercritical" href="https://gleasonator.com/tag/gendercritical">#gendercritical</a>. Boosts ≠ endorsements.'
// } // },
// }; // };
// const action = { // const action = {
// type: actions.COMPOSE_MENTION, // type: actions.COMPOSE_MENTION,
@ -679,10 +679,10 @@ describe('compose reducer', () => {
const initialPoll = Object({ const initialPoll = Object({
options: [ options: [
'', '',
'' '',
], ],
expires_in: 86400, expires_in: 86400,
multiple: false multiple: false,
}); });
const action = { const action = {
type: actions.COMPOSE_POLL_ADD, type: actions.COMPOSE_POLL_ADD,
@ -711,6 +711,11 @@ describe('compose reducer', () => {
// expires_in: 86400, // expires_in: 86400,
// multiple: false // multiple: false
// }); // });
// const state = ImmutableMap({ poll: initialPoll });
// const action = {
// type: actions.COMPOSE_POLL_OPTION_ADD,
// title: 'option 3',
// };
// const updatedPoll = Object({ // const updatedPoll = Object({
// options: [ // options: [
// 'option 1', // 'option 1',
@ -718,48 +723,65 @@ describe('compose reducer', () => {
// 'option 3', // 'option 3',
// ], // ],
// expires_in: 86400, // expires_in: 86400,
// multiple: false // multiple: false,
// }); // });
// const state = ImmutableMap({ poll: initialPoll });
// const action = {
// type: actions.COMPOSE_POLL_OPTION_ADD,
// title: 'option 3',
// };
// expect(reducer(state, action).toJS()).toMatchObject({ // expect(reducer(state, action).toJS()).toMatchObject({
// poll: updatedPoll, // poll: updatedPoll,
// }); // });
// }); // });
// it('should handle COMPOSE_POLL_OPTION_CHANGE', () => { it('should handle COMPOSE_POLL_OPTION_CHANGE', () => {
// const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); const initialPoll = Object({
// const action = { options: [
// type: actions.COMPOSE_POLL_OPTION_CHANGE, 'option 1',
// }; 'option 2',
// expect(reducer(state, action).toJS()).toMatchObject({ ],
// default_privacy: 'unlisted', expires_in: 86400,
// privacy: 'public', multiple: false,
// }); });
// }); const state = ImmutableMap({ poll: initialPoll });
// const action = {
type: actions.COMPOSE_POLL_OPTION_CHANGE,
index: 0,
title: 'change option',
};
const updatedPoll = Object({
options: [
'change option',
'option 2',
],
expires_in: 86400,
multiple: false,
});
expect(reducer(state, action).toJS()).toMatchObject({
poll: updatedPoll,
});
});
// it('should handle COMPOSE_POLL_OPTION_REMOVE', () => { // it('should handle COMPOSE_POLL_OPTION_REMOVE', () => {
// const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); // const initialPoll = Object({
// options: [
// 'option 1',
// 'option 2',
// ],
// expires_in: 86400,
// multiple: false,
// });
// const state = ImmutableMap({ poll: initialPoll });
// const action = { // const action = {
// type: actions.COMPOSE_POLL_OPTION_REMOVE, // type: actions.COMPOSE_POLL_OPTION_REMOVE,
// index: 1,
// }; // };
// const updatedPoll = Object({
// options: [
// 'option 1',
// ],
// expires_in: 86400,
// multiple: false,
// });
// expect(reducer(state, action).toJS()).toMatchObject({ // expect(reducer(state, action).toJS()).toMatchObject({
// default_privacy: 'unlisted', // poll: updatedPoll,
// privacy: 'public',
// });
// });
//
// it('should handle COMPOSE_POLL_SETTINGS_CHANGE', () => {
// const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'});
// const action = {
// type: actions.COMPOSE_POLL_SETTINGS_CHANGE,
// };
// expect(reducer(state, action).toJS()).toMatchObject({
// default_privacy: 'unlisted',
// privacy: 'public',
// }); // });
// }); // });
}); });