From 00c00191223c1294485c0e16afaed8f9ff83cd44 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 27 Oct 2015 17:44:55 -0700 Subject: [PATCH] [Time Conductor] Add test cases ...to cover FormatProvider. --- .../formats/test/FormatProviderSpec.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/platform/commonUI/formats/test/FormatProviderSpec.js b/platform/commonUI/formats/test/FormatProviderSpec.js index 5c86596f76..63b415711b 100644 --- a/platform/commonUI/formats/test/FormatProviderSpec.js +++ b/platform/commonUI/formats/test/FormatProviderSpec.js @@ -26,7 +26,35 @@ define( function (FormatProvider) { 'use strict'; + var KEYS = [ 'a', 'b', 'c' ]; + describe("The FormatProvider", function () { + var mockFormats, + mockFormatInstances, + provider; + + beforeEach(function () { + mockFormatInstances = KEYS.map(function (k) { + return jasmine.createSpyObj( + 'format-' + k, + [ 'parse', 'validate', 'format' ] + ); + }); + // Return constructors + mockFormats = KEYS.map(function (k, i) { + function MockFormat() { return mockFormatInstances[i]; } + MockFormat.key = k; + return MockFormat; + }); + provider = new FormatProvider(mockFormats); + }); + + it("looks up formats by key", function () { + KEYS.forEach(function (k, i) { + expect(provider.getFormat(k)) + .toEqual(mockFormatInstances[i]); + }); + }); }); }