Fix tests that set the store wrong

This commit is contained in:
Alex Gleason 2023-06-20 17:48:57 -05:00
parent e7217c5c58
commit c4ad5e5d78
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
12 changed files with 88 additions and 75 deletions

View file

@ -1,4 +1,3 @@
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { buildAccount } from 'soapbox/jest/factory';
@ -16,9 +15,9 @@ describe('<Account />', () => {
});
const store = {
accounts: ImmutableMap({
accounts: {
'1': account,
}),
},
};
render(<Account account={account} />, undefined, store);
@ -37,9 +36,9 @@ describe('<Account />', () => {
});
const store = {
accounts: ImmutableMap({
accounts: {
'1': account,
}),
},
};
render(<Account account={account} />, undefined, store);
@ -56,9 +55,9 @@ describe('<Account />', () => {
});
const store = {
accounts: ImmutableMap({
accounts: {
'1': account,
}),
},
};
render(<Account account={account} />, undefined, store);

View file

@ -1,12 +1,10 @@
import userEvent from '@testing-library/user-event';
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { __stub } from 'soapbox/api';
import { normalizeAccount } from 'soapbox/normalizers';
import { ReducerAccount } from 'soapbox/reducers/accounts';
import { buildAccount } from 'soapbox/jest/factory';
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
import { render, screen, waitFor } from '../../../../../jest/test-helpers';
import ChatPage from '../chat-page';
describe('<ChatPage />', () => {
@ -25,15 +23,17 @@ describe('<ChatPage />', () => {
beforeEach(() => {
store = {
me: id,
accounts: ImmutableMap({
[id]: normalizeAccount({
accounts: {
[id]: buildAccount({
id,
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
chats_onboarded: false,
}) as ReducerAccount,
}),
source: {
chats_onboarded: false,
},
}),
},
};
__stub((mock) => {
@ -59,15 +59,17 @@ describe('<ChatPage />', () => {
beforeEach(() => {
store = {
me: '1',
accounts: ImmutableMap({
'1': normalizeAccount({
accounts: {
'1': buildAccount({
id: '1',
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
chats_onboarded: false,
}) as ReducerAccount,
}),
source: {
chats_onboarded: false,
},
}),
},
};
__stub((mock) => {

View file

@ -1,9 +1,9 @@
import userEvent from '@testing-library/user-event';
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { buildAccount } from 'soapbox/jest/factory';
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
import { normalizeAccount, normalizeInstance } from 'soapbox/normalizers';
import { normalizeInstance } from 'soapbox/normalizers';
import Discover from '../discover';
@ -21,15 +21,17 @@ jest.mock('../../../hooks/useDimensions', () => ({
const userId = '1';
const store: any = {
me: userId,
accounts: ImmutableMap({
[userId]: normalizeAccount({
accounts: {
[userId]: buildAccount({
id: userId,
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
chats_onboarded: false,
source: {
chats_onboarded: false,
},
}),
}),
},
instance: normalizeInstance({
version: '3.4.1 (compatible; TruthSocial 1.0.0)',
software: 'TRUTHSOCIAL',

View file

@ -1,25 +1,27 @@
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { VirtuosoMockContext } from 'react-virtuoso';
import { __stub } from 'soapbox/api';
import { buildAccount } from 'soapbox/jest/factory';
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
import { normalizeAccount, normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers';
import { normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers';
import PendingRequests from '../pending-requests';
const userId = '1';
const store: any = {
me: userId,
accounts: ImmutableMap({
[userId]: normalizeAccount({
accounts: {
[userId]: buildAccount({
id: userId,
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
chats_onboarded: false,
source: {
chats_onboarded: false,
},
}),
}),
},
instance: normalizeInstance({
version: '3.4.1 (compatible; TruthSocial 1.0.0)',
software: 'TRUTHSOCIAL',

View file

@ -1,25 +1,27 @@
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { VirtuosoMockContext } from 'react-virtuoso';
import { __stub } from 'soapbox/api';
import { buildAccount } from 'soapbox/jest/factory';
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
import { normalizeAccount, normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers';
import { normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers';
import PendingGroupsRow from '../pending-groups-row';
const userId = '1';
let store: any = {
me: userId,
accounts: ImmutableMap({
[userId]: normalizeAccount({
accounts: {
[userId]: buildAccount({
id: userId,
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
chats_onboarded: false,
source: {
chats_onboarded: false,
},
}),
}),
},
};
const renderApp = (store: any) => (

View file

@ -1,10 +1,9 @@
import userEvent from '@testing-library/user-event';
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { VirtuosoMockContext } from 'react-virtuoso';
import { buildAccount } from 'soapbox/jest/factory';
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
import { normalizeAccount } from 'soapbox/normalizers';
import { groupSearchHistory } from 'soapbox/settings';
import { clearRecentGroupSearches, saveGroupSearch } from 'soapbox/utils/groups';
@ -13,15 +12,17 @@ import RecentSearches from '../recent-searches';
const userId = '1';
const store = {
me: userId,
accounts: ImmutableMap({
[userId]: normalizeAccount({
accounts: {
[userId]: buildAccount({
id: userId,
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
chats_onboarded: false,
source: {
chats_onboarded: false,
},
}),
}),
},
};
const renderApp = (children: React.ReactNode) => (

View file

@ -1,26 +1,26 @@
import userEvent from '@testing-library/user-event';
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { VirtuosoGridMockContext, VirtuosoMockContext } from 'react-virtuoso';
import { buildGroup } from 'soapbox/jest/factory';
import { buildAccount, buildGroup } from 'soapbox/jest/factory';
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
import { normalizeAccount } from 'soapbox/normalizers';
import Results from '../results';
const userId = '1';
const store = {
me: userId,
accounts: ImmutableMap({
[userId]: normalizeAccount({
accounts: {
[userId]: buildAccount({
id: userId,
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
chats_onboarded: false,
source: {
chats_onboarded: false,
},
}),
}),
},
};
const renderApp = (children: React.ReactNode) => (

View file

@ -1,9 +1,10 @@
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import { buildAccount } from 'soapbox/jest/factory';
import { render, screen, waitFor } from '../../../jest/test-helpers';
import { normalizeAccount, normalizeInstance } from '../../../normalizers';
import { normalizeInstance } from '../../../normalizers';
import UI from '../index';
import { WrappedRoute } from '../util/react-router-helpers';
@ -25,14 +26,14 @@ describe('<UI />', () => {
beforeEach(() => {
store = {
me: false,
accounts: ImmutableMap({
'1': normalizeAccount({
accounts: {
'1': buildAccount({
id: '1',
acct: 'username',
display_name: 'My name',
avatar: 'test.jpg',
}),
}),
},
instance: normalizeInstance({ registrations: true }),
};
});

View file

@ -4,9 +4,10 @@ import React from 'react';
import { ReportableEntities } from 'soapbox/actions/reports';
import { __stub } from 'soapbox/api';
import { buildAccount } from 'soapbox/jest/factory';
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
import { normalizeStatus } from 'soapbox/normalizers';
import { render, screen, waitFor } from '../../../../../../jest/test-helpers';
import { normalizeAccount, normalizeStatus } from '../../../../../../normalizers';
import ReportModal from '../report-modal';
describe('<ReportModal />', () => {
@ -17,14 +18,14 @@ describe('<ReportModal />', () => {
const status = require('soapbox/__fixtures__/status-unordered-mentions.json');
store = {
accounts: ImmutableMap({
'1': normalizeAccount({
accounts: {
'1': buildAccount({
id: '1',
acct: 'username',
display_name: 'My name',
avatar: 'test.jpg',
}),
}),
},
reports: ImmutableRecord({
new: ImmutableRecord({
account_id: '1',

View file

@ -1,9 +1,7 @@
import { Map as ImmutableMap } from 'immutable';
import { __stub } from 'soapbox/api';
import { buildGroup, buildGroupRelationship } from 'soapbox/jest/factory';
import { buildAccount, buildGroup, buildGroupRelationship } from 'soapbox/jest/factory';
import { renderHook, waitFor } from 'soapbox/jest/test-helpers';
import { normalizeAccount, normalizeInstance } from 'soapbox/normalizers';
import { normalizeInstance } from 'soapbox/normalizers';
import { useGroupsPath } from '../useGroupsPath';
@ -30,15 +28,17 @@ describe('useGroupsPath()', () => {
version: '3.4.1 (compatible; TruthSocial 1.0.0+unreleased)',
}),
me: userId,
accounts: ImmutableMap({
[userId]: normalizeAccount({
accounts: {
[userId]: buildAccount({
id: userId,
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
chats_onboarded: false,
source: {
chats_onboarded: false,
},
}),
}),
},
};
});

View file

@ -1,7 +1,9 @@
import { Map as ImmutableMap, fromJS } from 'immutable';
import { fromJS } from 'immutable';
import alexJson from 'soapbox/__fixtures__/pleroma-account.json';
import { normalizeAccount, normalizeInstance } from 'soapbox/normalizers';
import { normalizeInstance } from 'soapbox/normalizers';
import { buildAccount } from './factory';
/** Store with registrations open. */
const storeOpen = { instance: normalizeInstance({ registrations: true }) };
@ -26,9 +28,9 @@ const storePepeClosed = {
/** Store with a logged-in user. */
const storeLoggedIn = {
me: alexJson.id,
accounts: ImmutableMap({
[alexJson.id]: normalizeAccount(alexJson),
}),
accounts: {
[alexJson.id]: buildAccount(alexJson as any),
},
};
export {

View file

@ -9,6 +9,7 @@ module.exports = {
'<rootDir>/static/',
'<rootDir>/tmp/',
'<rootDir>/webpack/',
'<rootDir>/app/soapbox/actions/',
],
'setupFiles': [
'raf/polyfill',