Skip to content

Commit

Permalink
added test for app/components/draft/draft_post/draft_message/index.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat-Dabade committed Nov 26, 2024
1 parent 9a1c026 commit 85b4105
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Draft Message should match snapshot 1`] = `
<View
style={
{
"maxHeight": 721,
}
}
>
<RCTScrollView
keyboardShouldPersistTaps="always"
scrollEnabled={false}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
>
<View>
<View
onLayout={[Function]}
style={
[
{
"width": "100%",
},
]
}
>
<View
style={
[
{
"alignItems": "flex-start",
"flexDirection": "row",
"flexWrap": "wrap",
},
]
}
testID="markdown_paragraph"
>
<Text>
<Text
selectable={false}
style={
{
"color": "#3f4350",
"fontFamily": "OpenSans",
"fontSize": 16,
"fontWeight": "400",
"lineHeight": 24,
}
}
testID="markdown_text"
>
Hello, World!
</Text>
</Text>
</View>
</View>
</View>
</RCTScrollView>
</View>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import React from 'react';

import {renderWithEverything} from '@test/intl-test-helper';
import TestHelper from '@test/test_helper';

import DraftMessage from '.';

import type {Database} from '@nozbe/watermelondb';
import type DraftModel from '@typings/database/models/servers/draft';

describe('Draft Message', () => {
let database: Database;

beforeAll(async () => {
const server = await TestHelper.setupServerDatabase();
database = server.database;
});
it('should render the message', () => {
const props = {
draft: {
updateAt: 1633024800000,
message: 'Hello, World!',
channelId: 'channel_id',
rootId: '',
files: [],
metadata: {},
} as unknown as DraftModel,
layoutWidth: 100,
location: 'draft',
};
const {getByText} = renderWithEverything(
<DraftMessage {...props}/>, {database},
);
expect(getByText('Hello, World!')).toBeTruthy();
});

it('should match snapshot', () => {
const props = {
draft: {
updateAt: 1633024800000,
message: 'Hello, World!',
channelId: 'channel_id',
rootId: '',
files: [],
metadata: {},
} as unknown as DraftModel,
layoutWidth: 100,
location: 'draft',
};
const wrapper = renderWithEverything(
<DraftMessage {...props}/>, {database},
);

expect(wrapper.toJSON()).toMatchSnapshot();
});
});

0 comments on commit 85b4105

Please sign in to comment.