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>
80 lines
2.3 KiB
TypeScript
80 lines
2.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {type ComponentProps} from 'react';
|
|
|
|
import {Screens} from '@constants';
|
|
import DatabaseManager from '@database/manager';
|
|
import {renderWithEverything} from '@test/intl-test-helper';
|
|
|
|
import AutoCompleteSelector from './index';
|
|
|
|
import type {Database} from '@nozbe/watermelondb';
|
|
|
|
jest.mock('@screens/navigation', () => ({
|
|
navigateToScreen: jest.fn(),
|
|
navigateToSettingsScreen: jest.fn(),
|
|
}));
|
|
|
|
jest.mock('@store/settings_store', () => ({
|
|
setIntegrationsSelectCallback: jest.fn(),
|
|
setIntegrationsDynamicOptionsCallback: jest.fn(),
|
|
}));
|
|
|
|
describe('AutoCompleteSelector', () => {
|
|
let database: Database;
|
|
const serverUrl = 'https://server-url.com';
|
|
|
|
beforeEach(async () => {
|
|
await DatabaseManager.init([serverUrl]);
|
|
database = DatabaseManager.getServerDatabaseAndOperator(serverUrl).database;
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await DatabaseManager.destroyServerDatabase(serverUrl);
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
function getBaseProps(): Omit<ComponentProps<typeof AutoCompleteSelector>, 'teammateNameDisplay'> {
|
|
return {
|
|
testID: 'autocomplete.selector',
|
|
location: Screens.CHANNEL,
|
|
options: [
|
|
{value: 'a', text: 'Option A'},
|
|
{value: 'b', text: 'Option B'},
|
|
],
|
|
};
|
|
}
|
|
|
|
describe('omitMargins', () => {
|
|
it('should apply default container margins when omitMargins is false', () => {
|
|
const {root} = renderWithEverything(
|
|
<AutoCompleteSelector {...getBaseProps()}/>,
|
|
{database, serverUrl},
|
|
);
|
|
|
|
expect(root).toHaveStyle({
|
|
marginTop: 10,
|
|
marginBottom: 2,
|
|
marginRight: 8,
|
|
});
|
|
});
|
|
|
|
it('should zero out container margins when omitMargins is true', () => {
|
|
const {root} = renderWithEverything(
|
|
<AutoCompleteSelector
|
|
{...getBaseProps()}
|
|
omitMargins={true}
|
|
/>,
|
|
{database, serverUrl},
|
|
);
|
|
|
|
expect(root).toHaveStyle({
|
|
marginTop: 0,
|
|
marginBottom: 0,
|
|
marginRight: 0,
|
|
});
|
|
});
|
|
});
|
|
});
|