From 5db03bb1bd0d172ce8ecb9d5935c61257d8db9f6 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Thu, 27 Apr 2017 11:15:05 -0700 Subject: [PATCH] [Spec] update formatter mock, remove smelly test Update the formatter mock to implement the expected methods, such that formatting occurs properly. Remove a test that was validating the execution of a method as this was smelly-- it's not the method that is important, it's the result (that couldn't be obtained without the method). --- .../table/test/TableConfigurationSpec.js | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/platform/features/table/test/TableConfigurationSpec.js b/platform/features/table/test/TableConfigurationSpec.js index 9538335a86..484973dc9d 100644 --- a/platform/features/table/test/TableConfigurationSpec.js +++ b/platform/features/table/test/TableConfigurationSpec.js @@ -30,7 +30,6 @@ define( var mockDomainObject, mockAPI, mockTelemetryAPI, - mockTelemetryFormatter, table, mockModel; @@ -48,21 +47,27 @@ define( }; }); - mockTelemetryFormatter = jasmine.createSpyObj('telemetryFormatter', - [ - 'format' - ]); - mockTelemetryFormatter.format.andCallFake(function (valueIn) { - return valueIn; - }); - mockTelemetryAPI = jasmine.createSpyObj('telemetryAPI', [ 'getValueFormatter' ]); mockAPI = { telemetry: mockTelemetryAPI }; - mockTelemetryAPI.getValueFormatter.andReturn(mockTelemetryFormatter); + mockTelemetryAPI.getValueFormatter.andCallFake(function (metadata) { + var formatter = jasmine.createSpyObj( + 'telemetryFormatter:' + metadata.key, + [ + 'format', + 'parse' + ] + ); + var getter = function (datum) { + return datum[metadata.key]; + }; + formatter.format.andCallFake(getter); + formatter.parse.andCallFake(getter); + return formatter; + }); table = new Table(mockDomainObject, mockAPI); }); @@ -176,10 +181,6 @@ define( expect(rowValues['Range 1'].cssClass).toEqual("alarm-class"); }); - it("Uses telemetry formatter to appropriately format" + - " telemetry values", function () { - expect(mockTelemetryFormatter.format).toHaveBeenCalled(); - }); }); }); });