From 838f5cf251ff74494c832a3191b943e909a4c624 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 9 Apr 2020 17:00:20 +0300 Subject: [PATCH] Update _get_point.test.ts --- .../helpers/point_series/_get_point.test.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/legacy/core_plugins/vis_type_vislib/public/vislib/helpers/point_series/_get_point.test.ts b/src/legacy/core_plugins/vis_type_vislib/public/vislib/helpers/point_series/_get_point.test.ts index 5be3b9260393c..0c79c5b263cea 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/vislib/helpers/point_series/_get_point.test.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/helpers/point_series/_get_point.test.ts @@ -17,17 +17,22 @@ * under the License. */ +import { IFieldFormatsRegistry } from '../../../../../../../plugins/data/common'; import { getPoint } from './_get_point'; import { setFormatService } from '../../../services'; import { Aspect } from './point_series'; import { Table, Row, Column } from '../../types'; describe('getPoint', function() { + let deserialize: IFieldFormatsRegistry['deserialize']; + beforeAll(() => { + deserialize = jest.fn(() => ({ + convert: jest.fn(v => v), + })) as any; + setFormatService({ - deserialize: () => ({ - convert: jest.fn(v => v), - }), + deserialize, } as any); }); @@ -87,15 +92,13 @@ describe('getPoint', function() { expect(point).toHaveProperty('y', 3); }); - it('properly formats series values', function() { + it('should call deserialize', function() { const seriesAspect = [ { accessor: '1', format: { id: 'number', params: { pattern: '$' } } } as Aspect, ]; - const point = getPoint(table, xAspect, seriesAspect, row, 0, yAspect); + getPoint(table, xAspect, seriesAspect, row, 0, yAspect); - expect(point).toHaveProperty('x', 1); - expect(point).toHaveProperty('series', '2'); - expect(point).toHaveProperty('y', 3); + expect(deserialize).toHaveBeenCalledWith(seriesAspect[0].format); }); }); });