pl-fe: remove tests

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-10-23 18:27:42 +02:00
parent 08d7c8dfba
commit 2f1a9eb2d0

View File

@ -6,14 +6,10 @@ import { mockStore, rootState } from 'pl-fe/jest/test-helpers';
import { normalizeAccount } from 'pl-fe/normalizers/account';
import {
blockAccount,
createAccount,
fetchAccount,
fetchAccountByUsername,
fetchRelationships,
muteAccount,
unblockAccount,
unmuteAccount,
} from './accounts';
let store: ReturnType<typeof mockStore>;
@ -376,404 +372,6 @@ describe('fetchAccountByUsername()', () => {
});
});
describe('blockAccount()', () => {
const id = '1';
describe('when logged out', () => {
beforeEach(() => {
const state = { ...rootState, me: null };
store = mockStore(state);
});
it('should do nothing', async() => {
await store.dispatch(blockAccount(id));
const actions = store.getActions();
expect(actions).toEqual([]);
});
});
describe('when logged in', () => {
beforeEach(() => {
const state = { ...rootState, me: '123' };
store = mockStore(state);
});
describe('with a successful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/accounts/${id}/block`).reply(200, {});
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_BLOCK_REQUEST', id },
{
type: 'ACCOUNT_BLOCK_SUCCESS',
relationship: {},
statuses: ImmutableMap({}),
},
];
await store.dispatch(blockAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
describe('with an unsuccessful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/accounts/${id}/block`).networkError();
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_BLOCK_REQUEST', id },
{ type: 'ACCOUNT_BLOCK_FAIL', error: new Error('Network Error') },
];
await store.dispatch(blockAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
});
});
describe('unblockAccount()', () => {
const id = '1';
describe('when logged out', () => {
beforeEach(() => {
const state = { ...rootState, me: null };
store = mockStore(state);
});
it('should do nothing', async() => {
await store.dispatch(unblockAccount(id));
const actions = store.getActions();
expect(actions).toEqual([]);
});
});
describe('when logged in', () => {
beforeEach(() => {
const state = { ...rootState, me: '123' };
store = mockStore(state);
});
describe('with a successful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/accounts/${id}/unblock`).reply(200, {});
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_UNBLOCK_REQUEST', id },
{
type: 'ACCOUNT_UNBLOCK_SUCCESS',
relationship: {},
},
];
await store.dispatch(unblockAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
describe('with an unsuccessful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/accounts/${id}/unblock`).networkError();
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_UNBLOCK_REQUEST', id },
{ type: 'ACCOUNT_UNBLOCK_FAIL', error: new Error('Network Error') },
];
await store.dispatch(unblockAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
});
});
describe('muteAccount()', () => {
const id = '1';
describe('when logged out', () => {
beforeEach(() => {
const state = { ...rootState, me: null };
store = mockStore(state);
});
it('should do nothing', async() => {
await store.dispatch(unblockAccount(id));
const actions = store.getActions();
expect(actions).toEqual([]);
});
});
describe('when logged in', () => {
beforeEach(() => {
const state = { ...rootState, me: '123' };
store = mockStore(state);
});
describe('with a successful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/accounts/${id}/mute`).reply(200, {});
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_MUTE_REQUEST', id },
{
type: 'ACCOUNT_MUTE_SUCCESS',
relationship: {},
statuses: ImmutableMap({}),
},
];
await store.dispatch(muteAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
describe('with an unsuccessful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/accounts/${id}/mute`).networkError();
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_MUTE_REQUEST', id },
{ type: 'ACCOUNT_MUTE_FAIL', error: new Error('Network Error') },
];
await store.dispatch(muteAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
});
});
describe('unmuteAccount()', () => {
const id = '1';
describe('when logged out', () => {
beforeEach(() => {
const state = { ...rootState, me: null };
store = mockStore(state);
});
it('should do nothing', async() => {
await store.dispatch(unblockAccount(id));
const actions = store.getActions();
expect(actions).toEqual([]);
});
});
describe('when logged in', () => {
beforeEach(() => {
const state = { ...rootState, me: '123' };
store = mockStore(state);
});
describe('with a successful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/accounts/${id}/unmute`).reply(200, {});
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_UNMUTE_REQUEST', id },
{
type: 'ACCOUNT_UNMUTE_SUCCESS',
relationship: {},
},
];
await store.dispatch(unmuteAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
describe('with an unsuccessful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/accounts/${id}/unmute`).networkError();
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_UNMUTE_REQUEST', id },
{ type: 'ACCOUNT_UNMUTE_FAIL', error: new Error('Network Error') },
];
await store.dispatch(unmuteAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
});
});
describe('subscribeAccount()', () => {
const id = '1';
describe('when logged out', () => {
beforeEach(() => {
const state = { ...rootState, me: null };
store = mockStore(state);
});
it('should do nothing', async() => {
await store.dispatch(subscribeAccount(id));
const actions = store.getActions();
expect(actions).toEqual([]);
});
});
describe('when logged in', () => {
beforeEach(() => {
const state = { ...rootState, me: '123' };
store = mockStore(state);
});
describe('with a successful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/pleroma/accounts/${id}/subscribe`).reply(200, {});
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_SUBSCRIBE_REQUEST', id },
{
type: 'ACCOUNT_SUBSCRIBE_SUCCESS',
relationship: {},
},
];
await store.dispatch(subscribeAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
describe('with an unsuccessful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/pleroma/accounts/${id}/subscribe`).networkError();
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_SUBSCRIBE_REQUEST', id },
{ type: 'ACCOUNT_SUBSCRIBE_FAIL', error: new Error('Network Error') },
];
await store.dispatch(subscribeAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
});
});
describe('unsubscribeAccount()', () => {
const id = '1';
describe('when logged out', () => {
beforeEach(() => {
const state = { ...rootState, me: null };
store = mockStore(state);
});
it('should do nothing', async() => {
await store.dispatch(subscribeAccount(id));
const actions = store.getActions();
expect(actions).toEqual([]);
});
});
describe('when logged in', () => {
beforeEach(() => {
const state = { ...rootState, me: '123' };
store = mockStore(state);
});
describe('with a successful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/pleroma/accounts/${id}/unsubscribe`).reply(200, {});
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_UNSUBSCRIBE_REQUEST', id },
{
type: 'ACCOUNT_UNSUBSCRIBE_SUCCESS',
relationship: {},
},
];
await store.dispatch(unsubscribeAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
describe('with an unsuccessful API request', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPost(`/api/v1/pleroma/accounts/${id}/unsubscribe`).networkError();
});
});
it('should dispatch the correct actions', async() => {
const expectedActions = [
{ type: 'ACCOUNT_UNSUBSCRIBE_REQUEST', id },
{ type: 'ACCOUNT_UNSUBSCRIBE_FAIL', error: new Error('Network Error') },
];
await store.dispatch(unsubscribeAccount(id));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
});
});
describe('fetchRelationships()', () => {
const id = '1';