Skip to content

Commit

Permalink
Run localStorage fake on every test
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyAppeldoorn committed Aug 17, 2023
1 parent dcce1f4 commit 14c8454
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ const guideline = {
};

describe('<Guideline />', () => {
mockLocalstorage('1');
const editGuidelineMock = jest.fn();
let wrapper: ReactWrapper;

beforeEach(() => {
mockLocalstorage('1');
wrapper = mount(withMockedProviders(
<table>
<tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ const errorMocks = [


describe('<GuidelinesSection />', () => {
mockLocalstorage('1');
let wrapper: ReactWrapper;

beforeEach(() => {
mockLocalstorage('1');
wrapper = mount(withMockedProviders(<GuidelineSection />, mocks));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ const setup = (mocks: any) => {
};

describe('<IntegrationsSection />', () => {
mockLocalstorage('1');

beforeEach(() => {
mockLocalstorage('1');
setup(mocksWithoutSlack);
});

Expand Down
2 changes: 1 addition & 1 deletion src/modules/manage-team/sections/invite/Invite.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const mocks = [
];

describe('<Invite />', () => {
mockLocalstorage('1');
let wrapper: ReactWrapper;

function setup(invite: InviteModel) {
Expand All @@ -88,6 +87,7 @@ describe('<Invite />', () => {
}

beforeEach(() => {
mockLocalstorage('1');
mutationCalled = false;
queryCalled = false;
setup(pendingInvite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ const mocksWithError = [
];

describe('<InviteSection />', () => {
mockLocalstorage('1');
let wrapper: ReactWrapper;

beforeEach(() => {
mockLocalstorage('1');
wrapper = mount(withMockedProviders(<InviteSection />, mocks));
});

Expand All @@ -65,7 +65,7 @@ describe('<InviteSection />', () => {
await wait(0);
await wrapper.update();

expect(wrapper.containsMatchingElement(<p>Error! Network error: it broke</p>)).toBe(true);
expect(wrapper.containsMatchingElement(<p>Error! it broke</p>)).toBe(true);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ const goal: Goal = {
};

describe('<GoalRow />', () => {
mockLocalstorage('1');
let wrapper: ReactWrapper;
const editGoalMock = jest.fn(() => 1);

beforeEach(() => {
mockLocalstorage('1');
mutationCalled = false;
queryCalled = false;
wrapper = mount(withMockedProviders(
Expand Down
4 changes: 2 additions & 2 deletions src/modules/manage-team/sections/member/Members.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ const mocksWithError = [
];

describe('<Member />', () => {
mockLocalstorage('1');
let wrapper: ReactWrapper;

beforeEach(() => {
mockLocalstorage('1');
wrapper = mount(withMockedProviders(<MemberSection />, mocks));
});

Expand All @@ -67,7 +67,7 @@ describe('<Member />', () => {
await wait(0);
await wrapper.update();

expect(wrapper.containsMatchingElement(<p>Error! Network error: something went wrong</p>)).toBe(true);
expect(wrapper.containsMatchingElement(<p>Error! something went wrong</p>)).toBe(true);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/modules/statistics/Statistics.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const mocks = [

describe('<Statistics />', () => {
let wrapper: ReactWrapper;
mockLocalstorage('1');

beforeEach(() => {
mockLocalstorage('1');
wrapper = mount(withMockedProviders(<Statistics />, mocks));
});

Expand Down

0 comments on commit 14c8454

Please sign in to comment.