* update dev deps
* partial update dependencies
* update watermelondb
* update rn to 0.76.5, expo to 52.0.18 and others
* upgrade android firebase
* upgrade detox deps
* fix package-lock.json
* update emm and paste-input
* update turbo-log
* update network library
* fix tests
* review feedback
* fix Keyboard blocking signIn button
* Fall back to iphone 14 iOS 17.2 simulator as app crashes on iOS 17.4
* changes in deleteCredentialsForServer is causing a crash
* withOptions x2 clearly is wrong
* re-add cli-platform-apple fix
* fix: RN 0.76.5 issue with bottom sheet disappearing (#8478)
* experiment, using view vs BottomSheetView
* revert previous & try disabling enableDynamicSizing
* revert an unintended removal
---------
Co-authored-by: yasserfaraazkhan <attitude3cena.yf@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com>
(cherry picked from commit 2f3dfbbbfa)
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
104 lines
3.2 KiB
TypeScript
104 lines
3.2 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import ReactNativeHapticFeedback, {HapticFeedbackTypes} from 'react-native-haptic-feedback';
|
|
|
|
import {getIntlShape, emptyFunction, generateId, hapticFeedback, sortByNewest, isBetaApp, type SortByCreatAt} from './';
|
|
|
|
// Mock necessary modules
|
|
jest.mock('expo-application', () => ({
|
|
applicationId: 'com.example.rnbeta',
|
|
}));
|
|
|
|
jest.mock('react-intl', () => ({
|
|
createIntl: jest.fn((config) => config),
|
|
}));
|
|
|
|
jest.mock('react-native-haptic-feedback', () => ({
|
|
trigger: jest.fn(),
|
|
HapticFeedbackTypes: {
|
|
impactLight: 'impactLight',
|
|
impactMedium: 'impactMedium',
|
|
},
|
|
}));
|
|
|
|
jest.mock('@i18n', () => ({
|
|
getTranslations: jest.fn((locale) => ({message: `translations for ${locale}`})),
|
|
DEFAULT_LOCALE: 'en',
|
|
}));
|
|
|
|
describe('getIntlShape', () => {
|
|
it('should return intl shape with default locale', () => {
|
|
const result = getIntlShape();
|
|
expect(result).toEqual({
|
|
locale: 'en',
|
|
messages: {message: 'translations for en'},
|
|
});
|
|
});
|
|
|
|
it('should return intl shape with specified locale', () => {
|
|
const result = getIntlShape('fr');
|
|
expect(result).toEqual({
|
|
locale: 'fr',
|
|
messages: {message: 'translations for fr'},
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('emptyFunction', () => {
|
|
it('should do nothing', () => {
|
|
expect(emptyFunction()).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('generateId', () => {
|
|
it('should generate an ID without prefix', () => {
|
|
const result = generateId();
|
|
expect(result).toBe('12345678-1234-1234-1234-1234567890ab');
|
|
});
|
|
|
|
it('should generate an ID with prefix', () => {
|
|
const result = generateId('prefix');
|
|
expect(result).toBe('prefix-12345678-1234-1234-1234-1234567890ab');
|
|
});
|
|
});
|
|
|
|
describe('hapticFeedback', () => {
|
|
it('should trigger haptic feedback with default method', () => {
|
|
hapticFeedback();
|
|
expect(ReactNativeHapticFeedback.trigger).toHaveBeenCalledWith('impactLight', {
|
|
enableVibrateFallback: false,
|
|
ignoreAndroidSystemSettings: false,
|
|
});
|
|
});
|
|
|
|
it('should trigger haptic feedback with specified method', () => {
|
|
hapticFeedback(HapticFeedbackTypes.impactMedium);
|
|
expect(ReactNativeHapticFeedback.trigger).toHaveBeenCalledWith('impactMedium', {
|
|
enableVibrateFallback: false,
|
|
ignoreAndroidSystemSettings: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('sortByNewest', () => {
|
|
it('should sort by newest create_at', () => {
|
|
const a = {create_at: 2000} as SortByCreatAt;
|
|
const b = {create_at: 1000} as SortByCreatAt;
|
|
const result = sortByNewest(a, b);
|
|
expect(result).toBe(-1);
|
|
});
|
|
|
|
it('should sort by oldest create_at', () => {
|
|
const a = {create_at: 1000} as SortByCreatAt;
|
|
const b = {create_at: 2000} as SortByCreatAt;
|
|
const result = sortByNewest(a, b);
|
|
expect(result).toBe(1);
|
|
});
|
|
});
|
|
|
|
describe('isBetaApp', () => {
|
|
it('should be true if applicationId includes rnbeta', () => {
|
|
expect(isBetaApp).toBe(true);
|
|
});
|
|
});
|