mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-06 10:50:13 +00:00
* Mattermost Blocks * Move block renderer to its own components folder * Sync translation layer * UX fixes * Refactor button to use the button component * Code review * Fix CI * Add animations to collapse blocks * Add unit tests * Add e2e tests and related fixes * Address coderabbit comments * Address UX comments * Address feedback * Address coderabbit comments * Fix snapshots * Sync with webapp translation * Add node limit to button markdown node * Address feedback * i18n-extract * Fix test * Move image utils to the utils folder * Remove unneeded style * Revert build script change --------- Co-authored-by: Mattermost Build <build@mattermost.com>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {fireEvent} from '@testing-library/react-native';
|
|
import React from 'react';
|
|
import {ScrollView, Text} from 'react-native';
|
|
|
|
import {renderWithIntlAndTheme} from '@test/intl-test-helper';
|
|
|
|
import ClippedScrollContent from './clipped_scroll_content';
|
|
|
|
describe('ClippedScrollContent', () => {
|
|
const onExpand = jest.fn();
|
|
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
function renderClipped(maxHeight: number) {
|
|
const textContent = 'Tall content';
|
|
return renderWithIntlAndTheme(
|
|
<ClippedScrollContent
|
|
maxHeight={maxHeight}
|
|
onExpand={onExpand}
|
|
containerPadding={0}
|
|
testID='clipped.content'
|
|
>
|
|
<Text>{textContent}</Text>
|
|
</ClippedScrollContent>,
|
|
);
|
|
}
|
|
|
|
it('should not show expand button when content fits within max height', () => {
|
|
const {UNSAFE_getByType: getByType, queryByTestId} = renderClipped(500);
|
|
|
|
fireEvent(getByType(ScrollView), 'contentSizeChange', 0, 100);
|
|
|
|
expect(queryByTestId('clipped.content.expand.button')).toBeNull();
|
|
});
|
|
|
|
it('should show expand button and call onExpand when content overflows', () => {
|
|
const {UNSAFE_getByType: getByType, getByTestId} = renderClipped(100);
|
|
|
|
fireEvent(getByType(ScrollView), 'layout', {
|
|
nativeEvent: {layout: {width: 300, height: 100, x: 0, y: 0}},
|
|
});
|
|
fireEvent(getByType(ScrollView), 'contentSizeChange', 0, 250);
|
|
|
|
fireEvent.press(getByTestId('clipped.content.expand.button'));
|
|
expect(onExpand).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|