sforkowany z mirror/soapbox
test edits
rodzic
c216833222
commit
d415a432d2
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"notifications": {
|
||||||
|
"last_read_id": "35098814",
|
||||||
|
"version": 361,
|
||||||
|
"updated_at": "2019-11-26T22:37:25.239Z",
|
||||||
|
"pleroma": {
|
||||||
|
"unread_count": 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"home": {
|
||||||
|
"last_read_id": "103206604258487607",
|
||||||
|
"version": 468,
|
||||||
|
"updated_at": "2019-11-26T22:37:25.235Z",
|
||||||
|
"pleroma": {
|
||||||
|
"unread_count": 32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,217 @@
|
||||||
|
{
|
||||||
|
"account": {
|
||||||
|
"acct": "seanking",
|
||||||
|
"avatar": "https://gleasonator.com/images/avi.png",
|
||||||
|
"avatar_static": "https://gleasonator.com/images/avi.png",
|
||||||
|
"bot": false,
|
||||||
|
"created_at": "2020-05-24T01:46:12.000Z",
|
||||||
|
"display_name": "Sean King",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [],
|
||||||
|
"followers_count": 8,
|
||||||
|
"following_count": 4,
|
||||||
|
"header": "https://gleasonator.com/images/banner.png",
|
||||||
|
"header_static": "https://gleasonator.com/images/banner.png",
|
||||||
|
"id": "9vMAje101ngtjlMj7w",
|
||||||
|
"locked": false,
|
||||||
|
"note": "Hi, I'm Sean King, Founder and President of Sandia Mesa. I'll be here to try out new features and help test out some with Soapbox FE.",
|
||||||
|
"pleroma": {
|
||||||
|
"background_image": null,
|
||||||
|
"confirmation_pending": true,
|
||||||
|
"deactivated": false,
|
||||||
|
"hide_favorites": true,
|
||||||
|
"hide_followers": false,
|
||||||
|
"hide_followers_count": false,
|
||||||
|
"hide_follows": false,
|
||||||
|
"hide_follows_count": false,
|
||||||
|
"is_admin": false,
|
||||||
|
"is_moderator": false,
|
||||||
|
"relationship": {
|
||||||
|
"blocked_by": false,
|
||||||
|
"blocking": false,
|
||||||
|
"domain_blocking": false,
|
||||||
|
"endorsed": false,
|
||||||
|
"followed_by": true,
|
||||||
|
"following": true,
|
||||||
|
"id": "9vMAje101ngtjlMj7w",
|
||||||
|
"muting": false,
|
||||||
|
"muting_notifications": false,
|
||||||
|
"requested": false,
|
||||||
|
"showing_reblogs": true,
|
||||||
|
"subscribing": false
|
||||||
|
},
|
||||||
|
"skip_thread_containment": false,
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"fields": [],
|
||||||
|
"note": "Hi, I'm Sean King, Founder and President of Sandia Mesa. I'll be here to try out new features and help test out some with Soapbox FE.",
|
||||||
|
"pleroma": {
|
||||||
|
"actor_type": "Person",
|
||||||
|
"discoverable": false
|
||||||
|
},
|
||||||
|
"sensitive": false
|
||||||
|
},
|
||||||
|
"statuses_count": 15,
|
||||||
|
"url": "https://gleasonator.com/users/seanking",
|
||||||
|
"username": "seanking"
|
||||||
|
},
|
||||||
|
"created_at": "2020-06-10T02:54:39.000Z",
|
||||||
|
"emoji": "😢",
|
||||||
|
"id": "10744",
|
||||||
|
"pleroma": {
|
||||||
|
"is_seen": false
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"account": {
|
||||||
|
"acct": "alex",
|
||||||
|
"avatar": "https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg",
|
||||||
|
"avatar_static": "https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg",
|
||||||
|
"bot": false,
|
||||||
|
"created_at": "2020-01-08T01:25:43.000Z",
|
||||||
|
"display_name": "Alex Gleason",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "Website",
|
||||||
|
"value": "<a href=\"https://alexgleason.me\" rel=\"ugc\">https://alexgleason.me</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Pleroma+Soapbox",
|
||||||
|
"value": "<a href=\"https://soapbox.pub\" rel=\"ugc\">https://soapbox.pub</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Email",
|
||||||
|
"value": "alex@alexgleason.me"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gender identity",
|
||||||
|
"value": "Soyboy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"follow_requests_count": 0,
|
||||||
|
"followers_count": 474,
|
||||||
|
"following_count": 1083,
|
||||||
|
"header": "https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png",
|
||||||
|
"header_static": "https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png",
|
||||||
|
"id": "9v5bmRalQvjOy0ECcC",
|
||||||
|
"locked": false,
|
||||||
|
"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.",
|
||||||
|
"pleroma": {
|
||||||
|
"allow_following_move": true,
|
||||||
|
"background_image": null,
|
||||||
|
"confirmation_pending": false,
|
||||||
|
"deactivated": false,
|
||||||
|
"hide_favorites": true,
|
||||||
|
"hide_followers": false,
|
||||||
|
"hide_followers_count": false,
|
||||||
|
"hide_follows": false,
|
||||||
|
"hide_follows_count": false,
|
||||||
|
"is_admin": true,
|
||||||
|
"is_moderator": false,
|
||||||
|
"notification_settings": {
|
||||||
|
"followers": true,
|
||||||
|
"follows": true,
|
||||||
|
"non_followers": true,
|
||||||
|
"non_follows": true,
|
||||||
|
"privacy_option": false
|
||||||
|
},
|
||||||
|
"relationship": {
|
||||||
|
"blocked_by": false,
|
||||||
|
"blocking": false,
|
||||||
|
"domain_blocking": false,
|
||||||
|
"endorsed": false,
|
||||||
|
"followed_by": false,
|
||||||
|
"following": false,
|
||||||
|
"id": "9v5bmRalQvjOy0ECcC",
|
||||||
|
"muting": false,
|
||||||
|
"muting_notifications": false,
|
||||||
|
"requested": false,
|
||||||
|
"showing_reblogs": true,
|
||||||
|
"subscribing": false
|
||||||
|
},
|
||||||
|
"skip_thread_containment": false,
|
||||||
|
"tags": [],
|
||||||
|
"unread_conversation_count": 25
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "Website",
|
||||||
|
"value": "https://alexgleason.me"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Pleroma+Soapbox",
|
||||||
|
"value": "https://soapbox.pub"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Email",
|
||||||
|
"value": "alex@alexgleason.me"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gender identity",
|
||||||
|
"value": "Soyboy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"note": "Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.",
|
||||||
|
"pleroma": {
|
||||||
|
"actor_type": "Person",
|
||||||
|
"discoverable": false,
|
||||||
|
"no_rich_text": false,
|
||||||
|
"show_role": true
|
||||||
|
},
|
||||||
|
"privacy": "public",
|
||||||
|
"sensitive": false
|
||||||
|
},
|
||||||
|
"statuses_count": 4857,
|
||||||
|
"url": "https://gleasonator.com/users/alex",
|
||||||
|
"username": "alex"
|
||||||
|
},
|
||||||
|
"application": {
|
||||||
|
"name": "Web",
|
||||||
|
"website": null
|
||||||
|
},
|
||||||
|
"bookmarked": false,
|
||||||
|
"card": null,
|
||||||
|
"content": "At 10.72% test coverage, Soapbox FE now has 2x more than MastoFE, which only has 4.21%.<br/><br/>Pleroma FE doesn't seem to report coverage, but I suspect it's better than both of these combined.<br/><br/>I don't know how Mastodon got away with not writing tests for so long, but I feel like there could be an entire release dedicated only to going back and writing missing tests... jesus.",
|
||||||
|
"created_at": "2020-06-10T01:29:20.000Z",
|
||||||
|
"emojis": [],
|
||||||
|
"favourited": false,
|
||||||
|
"favourites_count": 4,
|
||||||
|
"id": "9vvNxoo5EFbbnfdXQu",
|
||||||
|
"in_reply_to_account_id": null,
|
||||||
|
"in_reply_to_id": null,
|
||||||
|
"language": null,
|
||||||
|
"media_attachments": [],
|
||||||
|
"mentions": [],
|
||||||
|
"muted": false,
|
||||||
|
"pinned": false,
|
||||||
|
"pleroma": {
|
||||||
|
"content": {
|
||||||
|
"text/plain": "At 10.72% test coverage, Soapbox FE now has 2x more than MastoFE, which only has 4.21%.Pleroma FE doesn't seem to report coverage, but I suspect it's better than both of these combined.I don't know how Mastodon got away with not writing tests for so long, but I feel like there could be an entire release dedicated only to going back and writing missing tests... jesus."
|
||||||
|
},
|
||||||
|
"conversation_id": 1168229,
|
||||||
|
"direct_conversation_id": null,
|
||||||
|
"emoji_reactions": [],
|
||||||
|
"expires_at": null,
|
||||||
|
"in_reply_to_account_acct": null,
|
||||||
|
"local": true,
|
||||||
|
"spoiler_text": {
|
||||||
|
"text/plain": ""
|
||||||
|
},
|
||||||
|
"thread_muted": false
|
||||||
|
},
|
||||||
|
"poll": null,
|
||||||
|
"reblog": null,
|
||||||
|
"reblogged": false,
|
||||||
|
"reblogs_count": 0,
|
||||||
|
"replies_count": 0,
|
||||||
|
"sensitive": false,
|
||||||
|
"spoiler_text": "",
|
||||||
|
"tags": [],
|
||||||
|
"uri": "https://gleasonator.com/objects/aa294f83-5a6c-4d2b-ba20-2b8bf69a82ba",
|
||||||
|
"url": "https://gleasonator.com/notice/9vvNxoo5EFbbnfdXQu",
|
||||||
|
"visibility": "public"
|
||||||
|
},
|
||||||
|
"type": "pleroma:emoji_reaction"
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
import {
|
import * as actions from 'soapbox/actions/notifications';
|
||||||
NOTIFICATIONS_EXPAND_SUCCESS,
|
|
||||||
} from 'soapbox/actions/notifications';
|
|
||||||
import reducer from '../notifications';
|
import reducer from '../notifications';
|
||||||
import notifications from 'soapbox/__fixtures__/notifications.json';
|
import notifications from 'soapbox/__fixtures__/notifications.json';
|
||||||
|
import markers from 'soapbox/__fixtures__/markers.json';
|
||||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
import { take } from 'lodash';
|
import { take } from 'lodash';
|
||||||
|
import { SAVE_MARKERS_SUCCESS } from 'soapbox/actions/markers';
|
||||||
|
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'soapbox/actions/accounts';
|
||||||
|
import notification from 'soapbox/__fixtures__/notification.json';
|
||||||
|
|
||||||
describe('notifications reducer', () => {
|
describe('notifications reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
|
@ -20,10 +22,10 @@ describe('notifications reducer', () => {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('NOTIFICATIONS_EXPAND_SUCCESS', () => {
|
it('should handle NOTIFICATIONS_EXPAND_SUCCESS', () => {
|
||||||
const state = undefined;
|
const state = undefined;
|
||||||
const action = {
|
const action = {
|
||||||
type: NOTIFICATIONS_EXPAND_SUCCESS,
|
type: actions.NOTIFICATIONS_EXPAND_SUCCESS,
|
||||||
notifications: take(notifications, 3),
|
notifications: take(notifications, 3),
|
||||||
next: null,
|
next: null,
|
||||||
skipLoading: true,
|
skipLoading: true,
|
||||||
|
@ -68,4 +70,153 @@ describe('notifications reducer', () => {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle SAVE_MARKERS_SUCCESS', () => {
|
||||||
|
const state = ImmutableMap({
|
||||||
|
unread: 1,
|
||||||
|
lastRead: '35098811',
|
||||||
|
});
|
||||||
|
const action = {
|
||||||
|
type: SAVE_MARKERS_SUCCESS,
|
||||||
|
markers: markers,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
|
unread: 3,
|
||||||
|
lastRead: '35098814',
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle NOTIFICATIONS_EXPAND_REQUEST', () => {
|
||||||
|
const state = ImmutableMap({
|
||||||
|
isLoading: false,
|
||||||
|
});
|
||||||
|
const action = {
|
||||||
|
type: actions.NOTIFICATIONS_EXPAND_REQUEST,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
|
isLoading: true,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle NOTIFICATIONS_EXPAND_FAIL', () => {
|
||||||
|
const state = ImmutableMap({
|
||||||
|
isLoading: true,
|
||||||
|
});
|
||||||
|
const action = {
|
||||||
|
type: actions.NOTIFICATIONS_EXPAND_FAIL,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
|
isLoading: false,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle NOTIFICATIONS_FILTER_SET', () => {
|
||||||
|
const state = ImmutableMap({
|
||||||
|
items: ImmutableList([
|
||||||
|
ImmutableMap({
|
||||||
|
id: '10744',
|
||||||
|
type: 'pleroma:emoji_reaction',
|
||||||
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
created_at: '2020-06-10T02:54:39.000Z',
|
||||||
|
status: '9vvNxoo5EFbbnfdXQu',
|
||||||
|
emoji: '😢',
|
||||||
|
is_seen: false,
|
||||||
|
}),
|
||||||
|
ImmutableMap({
|
||||||
|
id: '10743',
|
||||||
|
type: 'favourite',
|
||||||
|
account: '9v5c6xSEgAi3Zu1Lv6',
|
||||||
|
created_at: '2020-06-10T02:51:05.000Z',
|
||||||
|
status: '9vvNxoo5EFbbnfdXQu',
|
||||||
|
emoji: undefined,
|
||||||
|
is_seen: true,
|
||||||
|
}),
|
||||||
|
ImmutableMap({
|
||||||
|
id: '10741',
|
||||||
|
type: 'favourite',
|
||||||
|
account: '9v5cKMOPGqPcgfcWp6',
|
||||||
|
created_at: '2020-06-10T02:05:06.000Z',
|
||||||
|
status: '9vvNxoo5EFbbnfdXQu',
|
||||||
|
emoji: undefined,
|
||||||
|
is_seen: true,
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
hasMore: false,
|
||||||
|
top: false,
|
||||||
|
unread: 1,
|
||||||
|
isLoading: false,
|
||||||
|
queuedNotifications: ImmutableList(),
|
||||||
|
totalQueuedNotificationsCount: 0,
|
||||||
|
lastRead: -1,
|
||||||
|
});
|
||||||
|
const action = {
|
||||||
|
type: actions.NOTIFICATIONS_FILTER_SET,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
|
items: ImmutableList(),
|
||||||
|
hasMore: true,
|
||||||
|
top: false,
|
||||||
|
unread: 1,
|
||||||
|
isLoading: false,
|
||||||
|
queuedNotifications: ImmutableList(),
|
||||||
|
totalQueuedNotificationsCount: 0,
|
||||||
|
lastRead: -1,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle NOTIFICATIONS_SCROLL_TOP by changing unread to 0 when top = true', () => {
|
||||||
|
const state = ImmutableMap({
|
||||||
|
unread: 1,
|
||||||
|
});
|
||||||
|
const action = {
|
||||||
|
type: actions.NOTIFICATIONS_SCROLL_TOP,
|
||||||
|
top: true,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
|
unread: 0,
|
||||||
|
top: true,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle NOTIFICATIONS_SCROLL_TOP by not changing unread val when top = false', () => {
|
||||||
|
const state = ImmutableMap({
|
||||||
|
unread: 3,
|
||||||
|
});
|
||||||
|
const action = {
|
||||||
|
type: actions.NOTIFICATIONS_SCROLL_TOP,
|
||||||
|
top: false,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
|
unread: 3,
|
||||||
|
top: false,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle NOTIFICATIONS_UPDATE, when top = false, increment unread', () => {
|
||||||
|
const state = ImmutableMap({
|
||||||
|
items: ImmutableList(),
|
||||||
|
top: false,
|
||||||
|
unread: 1,
|
||||||
|
});
|
||||||
|
//const notification = notification;
|
||||||
|
const action = {
|
||||||
|
type: actions.NOTIFICATIONS_UPDATE,
|
||||||
|
notification: notification,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||||
|
items: ImmutableList([
|
||||||
|
ImmutableMap({
|
||||||
|
id: '10744',
|
||||||
|
type: 'pleroma:emoji_reaction',
|
||||||
|
account: '9vMAje101ngtjlMj7w',
|
||||||
|
created_at: '2020-06-10T02:54:39.000Z',
|
||||||
|
status: '9vvNxoo5EFbbnfdXQu',
|
||||||
|
emoji: '😢',
|
||||||
|
is_seen: false,
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
top: false,
|
||||||
|
unread: 2,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Ładowanie…
Reference in New Issue