mattermost-mobile/app/screens/post_options/post_options_utils.test.js
Saturnino Abril b153dd96a1
[MM-13412 & MM-13711] Allow showing of all post options if possible to fit 75% of the screen height (#2501)
* allow showing all options if possible to fit 60% of the screen height

* change max initial position from 60% to 70%

* fix broken UI of the bottom part of post options

* change to 75%
2019-01-30 01:07:58 +08:00

41 lines
1.4 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {getInitialPosition, MAX_INITIAL_POSITION_MULTIPLIER} from './post_options_utils';
describe('should match return value of getInitialPosition', () => {
const testCases = [
{
input: {deviceHeight: 600, marginFromTop: 400},
output: 200,
}, {
input: {deviceHeight: 600, marginFromTop: 300},
output: 300,
}, {
input: {deviceHeight: 600, marginFromTop: 50},
output: 404.5,
}, {
input: {deviceHeight: 1000, marginFromTop: 250},
output: 750,
}, {
input: {deviceHeight: 1000, marginFromTop: 150},
output: 704.5,
}, {
input: {deviceHeight: 1000, marginFromTop: 400},
output: 600,
},
];
for (const testCase of testCases) {
const {input, output} = testCase;
const maxInitialPosition = input.deviceHeight * MAX_INITIAL_POSITION_MULTIPLIER;
test('should match initial position', () => {
const initialPosition = getInitialPosition(input.deviceHeight, input.marginFromTop);
expect(initialPosition).toEqual(output);
// should not exceed maximum initial position at 75% of screen height
expect(initialPosition).toBeLessThanOrEqual(maxInitialPosition);
});
}
});