mattermost-mobile/app/components/burn_on_read_label/index.test.tsx
Harshil Sharma 4a05ae0cfd
Added BoR indicator in scheduled posts (#9355)
* Added type column to scheduled post and draft table

* removed console log

* fixed a test

* fixes

* Restored ununtended changes

* Added BoR indicator in scheduled posts

* used fixed padding

* used Tag for BoR chip

* test: add comprehensive tests for formatTime humanReadable parameter

* test: add initial test file for burn on read label component

* test: add comprehensive tests for BoRLabel component

* test: update BoRLabel tests to use deep rendering and remove mocks

* test: fix renderWithIntl import and usage in BoRLabel test

* refactor: Update BoRLabel tests to use renderWithIntl and remove formatTime mock

* refactor: simplify imports and remove renderWithIntl mock in test file

* Updated tests

* reset unintended changes

* reset unintended changes

* reset unintended changes

* i18n fixes

* fixed tests

* Matched BOR tag size to post priority tag

* Review fixes
2026-01-12 20:09:24 +05:30

80 lines
2.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {renderWithIntl} from '@test/intl-test-helper';
import BoRLabel from './index';
describe('BoRLabel', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('should render with correct message and props', () => {
const {getByTestId} = renderWithIntl(
<BoRLabel
durationSeconds={300}
id='test-post-id'
/>,
);
const tag = getByTestId('test-post-id_bor_label');
expect(tag).toBeVisible();
expect(tag).toHaveTextContent('BURN ON READ (5m)');
});
it('should render without postId', () => {
const {getByTestId} = renderWithIntl(
<BoRLabel durationSeconds={60}/>,
);
const tag = getByTestId('bor_label');
expect(tag).toBeVisible();
expect(tag).toHaveTextContent('BURN ON READ (1m)');
});
it('should format duration correctly for seconds', () => {
const {getByTestId} = renderWithIntl(
<BoRLabel
durationSeconds={30}
id='test'
/>,
);
const tag = getByTestId('test_bor_label');
expect(tag).toHaveTextContent('BURN ON READ (30s)');
});
it('should format duration correctly for hours', () => {
const {getByTestId} = renderWithIntl(
<BoRLabel
durationSeconds={7200}
id='test'
/>,
);
const tag = getByTestId('test_bor_label');
expect(tag).toHaveTextContent('BURN ON READ (2h)');
});
it('should generate correct testID with postId', () => {
const {getByTestId} = renderWithIntl(
<BoRLabel
durationSeconds={120}
id='test-post'
/>,
);
expect(getByTestId('test-post_bor_label')).toBeVisible();
});
it('should generate correct testID without postId', () => {
const {getByTestId} = renderWithIntl(
<BoRLabel durationSeconds={120}/>,
);
expect(getByTestId('bor_label')).toBeVisible();
});
});