client: 2353 sort ip in dns rewrites

Close #2353

Squashed commit of the following:

commit 1072b124c68ff09c6d718acb3aea625fd7b38c4f
Merge: 77e9a6f10 6aacb2105
Author: Artem Baskal <a.baskal@adguard.com>
Date:   Tue Dec 8 14:27:06 2020 +0300

    Merge branch 'master' into 2353-fix-sort-ip

commit 77e9a6f1013e200346b0dc332fd6b7e9e88c8ade
Author: Artem Baskal <a.baskal@adguard.com>
Date:   Mon Dec 7 17:38:24 2020 +0300

    client: 2353 sort ip in dns rewrites
This commit is contained in:
Artem Baskal 2020-12-08 15:31:20 +03:00
parent 6aacb2105c
commit b7bf7f78df
3 changed files with 7 additions and 5 deletions

View File

@ -273,15 +273,15 @@ describe('sortIp', () => {
});
});
describe('invalid input', () => {
const originalError = console.error;
const originalWarn = console.warn;
beforeEach(() => {
console.error = jest.fn();
console.warn = jest.fn();
});
afterEach(() => {
expect(console.error).toHaveBeenCalled();
console.error = originalError;
expect(console.warn).toHaveBeenCalled();
console.warn = originalWarn;
});
test('invalid strings', () => {

View File

@ -2,6 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactTable from 'react-table';
import { withTranslation } from 'react-i18next';
import { sortIp } from '../../../helpers/helpers';
class Table extends Component {
cellWrap = ({ value }) => (
@ -21,6 +22,7 @@ class Table extends Component {
{
Header: this.props.t('answer'),
accessor: 'answer',
sortMethod: sortIp,
Cell: this.cellWrap,
},
{

View File

@ -687,7 +687,7 @@ export const sortIp = (a, b) => {
return 0;
} catch (e) {
console.error(e);
console.warn(e);
return 0;
}
};