* Add channelEntry action * Refactor appEntry * Lint fix * Some duplication removed * Refactor app entry * Refactor app entry and add prepareDestroyPermanentlyWithAssociations * Handle team deletion * Sync channels * Lint fix * Address review comments, take 1 * Address review comments, take 2 * Set initial channel ID to empty * Fix types * sort imports * clean up app entry point * Fix post header & highlight reply bar * Style channel list text * iOS Pods sync * Rename goToChannel to goToHome * Sync ios Gemfile.lock Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {fireEvent, waitFor} from '@testing-library/react-native';
|
|
import React from 'react';
|
|
|
|
import {Preferences} from '@constants';
|
|
import {renderWithIntl} from '@test/intl-test-helper';
|
|
|
|
import Mfa from './index';
|
|
|
|
jest.mock('@actions/remote/session', () => {
|
|
return {
|
|
login: jest.fn().mockResolvedValue({error: undefined, hasTeams: true}),
|
|
};
|
|
});
|
|
|
|
describe('*** MFA Screen ***', () => {
|
|
const baseProps = {
|
|
config: {},
|
|
goToHome: jest.fn(),
|
|
loginId: 'loginId',
|
|
password: 'passwd',
|
|
license: {},
|
|
serverUrl: 'https://locahost:8065',
|
|
theme: Preferences.THEMES.denim,
|
|
};
|
|
|
|
test('MFA screen should match snapshot', () => {
|
|
const {toJSON} = renderWithIntl(<Mfa {...baseProps}/>);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should call login method on submit', async () => {
|
|
const props = {
|
|
...baseProps,
|
|
goToHome: jest.fn(),
|
|
};
|
|
|
|
const spyOnGoToHome = jest.spyOn(props, 'goToHome');
|
|
const {getByTestId} = renderWithIntl(<Mfa {...props}/>);
|
|
const submitBtn = getByTestId('login_mfa.submit');
|
|
const inputText = getByTestId('login_mfa.input');
|
|
fireEvent.changeText(inputText, 'token123');
|
|
|
|
await waitFor(() => {
|
|
fireEvent.press(submitBtn);
|
|
});
|
|
|
|
expect(spyOnGoToHome).toHaveBeenCalled();
|
|
});
|
|
});
|