Skip to content

Commit

Permalink
refactor: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
longyulongyu committed Oct 25, 2024
1 parent d0b018e commit 7272a8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions packages/lib/src/components/UPI/UPI.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('UPI', () => {
describe('select the QR code mode', () => {
test('should be valid', async () => {
isMobileMock.mockReturnValue(false);
const upi = new UPI({ ...props, defaultMode: UpiMode.QrCode });
const upi = new UPI(global.core, { ...props, defaultMode: 'qrCode' });
render(upi.render());
await waitFor(() => {
expect(upi.isValid).toBe(true);
Expand All @@ -118,7 +118,7 @@ describe('UPI', () => {
describe('select the vpa mode', () => {
test('should not be valid on init', async () => {
isMobileMock.mockReturnValue(false);
const upi = new UPI({ ...props, defaultMode: UpiMode.Vpa });
const upi = new UPI(global.core, { ...props, defaultMode: 'vpa' });
render(upi.render());
await waitFor(() => {
expect(upi.isValid).toBe(false);
Expand All @@ -127,7 +127,7 @@ describe('UPI', () => {

test('should be valid when filling in the vpa', async () => {
isMobileMock.mockReturnValue(false);
const upi = new UPI({ ...props, defaultMode: UpiMode.Vpa });
const upi = new UPI(global.core, { ...props, defaultMode: 'vpa' });
render(upi.render());
const user = userEvent.setup();
const vpaInput = await screen.findByLabelText(/Enter UPI ID \/ VPA/i);
Expand All @@ -142,15 +142,15 @@ describe('UPI', () => {
});

test('should not be valid on init', async () => {
const upi = new UPI({ ...props, apps: [{ id: 'gpay', name: 'Google Pay' }] });
const upi = new UPI(global.core, { ...props, apps: [{ id: 'gpay', name: 'Google Pay' }] });
render(upi.render());
await waitFor(() => {
expect(upi.isValid).toBe(false);
});
});

test('should be valid when selecting other apps', async () => {
const upi = new UPI({ ...props, apps: [{ id: 'gpay', name: 'Google Pay' }] });
const upi = new UPI(global.core, { ...props, apps: [{ id: 'gpay', name: 'Google Pay' }] });
render(upi.render());
const user = userEvent.setup();
const radioButton = await screen.findByRole('radio', { name: /google pay/i });
Expand All @@ -159,7 +159,7 @@ describe('UPI', () => {
});

test('should not be valid when selecting upi collect', async () => {
const upi = new UPI({ ...props, apps: [{ id: 'gpay', name: 'Google Pay' }] });
const upi = new UPI(global.core, { ...props, apps: [{ id: 'gpay', name: 'Google Pay' }] });
render(upi.render());
const user = userEvent.setup();
const radioButton = await screen.findByRole('radio', { name: /Enter UPI ID/i });
Expand All @@ -168,7 +168,7 @@ describe('UPI', () => {
});

test('should be valid when filling the vpa', async () => {
const upi = new UPI({ ...props, apps: [{ id: 'gpay', name: 'Google Pay' }] });
const upi = new UPI(global.core, { ...props, apps: [{ id: 'gpay', name: 'Google Pay' }] });
render(upi.render());
const user = userEvent.setup();
const radioButton = await screen.findByRole('radio', { name: /Enter UPI ID/i });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function UPIComponent({ defaultMode, onChange, onUpdateMode, payB
const { i18n } = useCoreContext();
const getImage = useImage();
const [status, setStatus] = useState<UIElementStatus>('ready');
const [isValid, setIsValid] = useState<boolean>(defaultMode === UpiMode.QrCode);
const [isValid, setIsValid] = useState<boolean>(defaultMode === 'qrCode');
const [mode, setMode] = useState<UpiMode>(defaultMode);
const [vpa, setVpa] = useState<string>('');
const [vpaInputHandlers, setVpaInputHandlers] = useState<VpaInputHandlers>(null);
Expand Down

0 comments on commit 7272a8c

Please sign in to comment.