Skip to content

Commit

Permalink
[MM-18918] Migrate 'utils/server_version.jsx' and associated tests to…
Browse files Browse the repository at this point in the history
… TypeScript (mattermost#3842)

* Migrate 'utils/server_version.jsx' and tests to TypeScript

* remove undefined test
  • Loading branch information
mjthomp95 authored and kgeorgiou committed Oct 22, 2019
1 parent d1f67a2 commit 1e83897
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
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

0 comments on commit 1e83897

Please sign in to comment.