diff --git a/__tests__/utils/sort-by-descend.js b/__tests__/utils/sort-by-descend.js new file mode 100644 index 0000000..d56b37c --- /dev/null +++ b/__tests__/utils/sort-by-descend.js @@ -0,0 +1,13 @@ +// @flow + +import 'jest-dom/extend-expect'; + +import { sortByDescend } from '../../app/utils/sort-by-descend'; + +describe('truncateAddress', () => { + test('should truncate ZEC address', () => { + expect( + sortByDescend('id')([{ id: 5 }, { id: 2 }, { id: 1 }, { id: 0 }, { id: 1 }, { id: 1 }]), + ).toEqual([{ id: 5 }, { id: 2 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 0 }]); + }); +}); diff --git a/__tests__/utils/sort-by.js b/__tests__/utils/sort-by.js new file mode 100644 index 0000000..6d48fae --- /dev/null +++ b/__tests__/utils/sort-by.js @@ -0,0 +1,13 @@ +// @flow + +import 'jest-dom/extend-expect'; + +import { sortBy } from '../../app/utils/sort-by'; + +describe('truncateAddress', () => { + test('should truncate ZEC address', () => { + expect( + sortBy('id')([{ id: 5 }, { id: 2 }, { id: 1 }, { id: 0 }, { id: 1 }, { id: 1 }]), + ).toEqual([{ id: 0 }, { id: 1 }, { id: 1 }, { id: 1 }, { id: 2 }, { id: 5 }]); + }); +}); diff --git a/app/containers/dashboard.js b/app/containers/dashboard.js index 0643244..e2477a6 100644 --- a/app/containers/dashboard.js +++ b/app/containers/dashboard.js @@ -15,7 +15,7 @@ import { loadWalletSummarySuccess, loadWalletSummaryError, } from '../redux/modules/wallet'; -import { sortByDescend } from '../utils/sort-by'; +import { sortByDescend } from '../utils/sort-by-descend'; import type { AppState } from '../types/app-state'; import type { Dispatch } from '../types/redux'; diff --git a/app/containers/transactions.js b/app/containers/transactions.js index ed61110..1ab4818 100644 --- a/app/containers/transactions.js +++ b/app/containers/transactions.js @@ -17,7 +17,7 @@ import rpc from '../../services/api'; import { listShieldedTransactions } from '../../services/shielded-transactions'; import store from '../../config/electron-store'; -import { sortByDescend } from '../utils/sort-by'; +import { sortByDescend } from '../utils/sort-by-descend'; import type { AppState } from '../types/app-state'; import type { Dispatch } from '../types/redux'; diff --git a/app/utils/sort-by-descend.js b/app/utils/sort-by-descend.js new file mode 100644 index 0000000..fafa6ed --- /dev/null +++ b/app/utils/sort-by-descend.js @@ -0,0 +1,5 @@ +// @flow +/* eslint-disable max-len */ + +// $FlowFixMe +export const sortByDescend = (field: string) => (arr: T[]): T[] => arr.sort((a, b) => (a[field] < b[field] ? 1 : -1)); diff --git a/app/utils/sort-by.js b/app/utils/sort-by.js index dee60ad..8c506fd 100644 --- a/app/utils/sort-by.js +++ b/app/utils/sort-by.js @@ -3,6 +3,3 @@ // $FlowFixMe export const sortBy = (field: string) => (arr: T[]): T[] => arr.sort((a, b) => (a[field] > b[field] ? 1 : -1)); - -// $FlowFixMe -export const sortByDescend = (field: string) => (arr: T[]): T[] => arr.sort((a, b) => (a[field] < b[field] ? 1 : -1));