-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Migrate WarningsViewModel to React (#13748)
* refactor: Migrate WarningsViewModel to React * error message from zustand * prepare object and check by content?.currentType * onBgClick * have duplicated ids * secondary actions * filter null actions * simplify * map * alreadyOpen * change name to primary modal * fix tests * first step to delete amplify * step 2 of deleting amplify * move to index * fix import errors * default values * use react testing library
- Loading branch information
1 parent
067c432
commit 2e7cfcf
Showing
42 changed files
with
730 additions
and
564 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/script/components/Modals/PrimaryModal/PrimaryModal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2022 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import {render, fireEvent, act} from '@testing-library/react'; | ||
import PrimaryModal from '.'; | ||
import {PrimaryModalComponent} from './PrimaryModal'; | ||
|
||
describe('PrimaryModal', () => { | ||
it('does not render when no item is in the queue', async () => { | ||
const {getByTestId} = render(<PrimaryModalComponent />); | ||
const PrimaryModalWrapper = getByTestId('primary-modals-container'); | ||
expect(PrimaryModalWrapper.children[0].getAttribute('style')).toBe('display: none;'); | ||
}); | ||
|
||
it('correctly calls action callback', async () => { | ||
const {getByTestId} = render(<PrimaryModalComponent />); | ||
const actionCallback = jest.fn(); | ||
act(() => { | ||
PrimaryModal.show(PrimaryModal.type.CONFIRM, { | ||
primaryAction: { | ||
action: actionCallback, | ||
text: 'test-text', | ||
}, | ||
secondaryAction: { | ||
action: () => {}, | ||
text: 'secondary-text', | ||
}, | ||
text: { | ||
message: 'test-message', | ||
title: 'test-title', | ||
}, | ||
}); | ||
}); | ||
|
||
const actionButton = getByTestId('do-action'); | ||
fireEvent.click(actionButton); | ||
|
||
expect(actionCallback).toHaveBeenCalledTimes(1); | ||
}); | ||
it('correctly calls secondary action callback', async () => { | ||
const {getByTestId} = render(<PrimaryModalComponent />); | ||
const secondaryActionCallback = jest.fn(); | ||
act(() => { | ||
PrimaryModal.show(PrimaryModal.type.CONFIRM, { | ||
primaryAction: { | ||
action: () => {}, | ||
text: 'test-text', | ||
}, | ||
secondaryAction: { | ||
action: secondaryActionCallback, | ||
text: 'secondary-text', | ||
}, | ||
text: { | ||
message: 'test-message', | ||
title: 'test-title', | ||
}, | ||
}); | ||
}); | ||
|
||
const secondaryActionButton = getByTestId('do-secondary'); | ||
fireEvent.click(secondaryActionButton); | ||
|
||
expect(secondaryActionCallback).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
Oops, something went wrong.