Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-18918] Migrate 'utils/server_version.jsx' and associated tests to TypeScript #3842

Merged
merged 2 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/announcement_bar/version_bar/version_bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PropTypes from 'prop-types';

import {FormattedMessage} from 'react-intl';

import {equalServerVersions} from 'utils/server_version.jsx';
import {equalServerVersions} from 'utils/server_version';
import {AnnouncementBarTypes} from 'utils/constants.jsx';

import AnnouncementBar from '../announcement_bar.jsx';
Expand Down
2 changes: 1 addition & 1 deletion components/system_notice/notices.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react';

import FormattedMarkdownMessage from 'components/formatted_markdown_message';

import * as ServerVersion from 'utils/server_version.jsx';
import * as ServerVersion from 'utils/server_version';
import * as UserAgent from 'utils/user_agent.jsx';

import mattermostIcon from 'images/icon50x50.png';
Expand Down
14 changes: 1 addition & 13 deletions utils/server_version.test.jsx → utils/server_version.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {equalServerVersions, isServerVersionGreaterThanOrEqualTo} from 'utils/server_version.jsx';
import {equalServerVersions, isServerVersionGreaterThanOrEqualTo} from 'utils/server_version';

describe('utils/server_version/equalServerVersions', () => {
test('should handle undefined values', () => {
const a = undefined; // eslint-disable-line no-undefined
const b = null;
expect(equalServerVersions(a, b)).toEqual(true);
});

test('should consider two empty versions as equal', () => {
const a = '';
const b = '';
Expand Down Expand Up @@ -66,12 +60,6 @@ describe('utils/server_version/equalServerVersions', () => {
});

describe('utils/server_version/isServerVersionGreaterThanOrEqualTo', () => {
test('should handle undefined values', () => {
const a = undefined; // eslint-disable-line no-undefined
const b = null;
expect(isServerVersionGreaterThanOrEqualTo(a, b)).toEqual(true);
});

test('should consider two empty versions as equal', () => {
const a = '';
const b = '';
Expand Down
4 changes: 2 additions & 2 deletions utils/server_version.jsx → utils/server_version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* 4.7.0.dev.3034fbc5fd566195d1b53e03890e35ff.true
* 4.7.1.dev.d131dd02c5e6eec4693d9a0698aff95c.true
*/
export function equalServerVersions(a, b) {
export function equalServerVersions(a: string, b: string): boolean {
if (a === b) {
return true;
}
Expand All @@ -36,7 +36,7 @@ export function equalServerVersions(a, b) {
* eg. currentVersion = 4.16.0, compareVersion = 4.17.0 returns false
* currentVersion = 4.16.1, compareVersion = 4.16.1 returns true
*/
export function isServerVersionGreaterThanOrEqualTo(currentVersion, compareVersion) {
export function isServerVersionGreaterThanOrEqualTo(currentVersion: string, compareVersion: string): boolean {
if (currentVersion === compareVersion) {
return true;
}
Expand Down