mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 09:26:45 +00:00
[Time Conductor] Update specs
...to reflect changes to how unspecified versus unknown formats are handled.
This commit is contained in:
parent
7f571415dc
commit
f42498ab60
@ -30,6 +30,7 @@ define(
|
||||
|
||||
describe("The FormatProvider", function () {
|
||||
var mockFormats,
|
||||
mockLog,
|
||||
mockFormatInstances,
|
||||
provider;
|
||||
|
||||
@ -40,13 +41,14 @@ define(
|
||||
[ 'parse', 'validate', 'format' ]
|
||||
);
|
||||
});
|
||||
mockLog = jasmine.createSpyObj('$log', ['error', 'warn']);
|
||||
// Return constructors
|
||||
mockFormats = KEYS.map(function (k, i) {
|
||||
function MockFormat() { return mockFormatInstances[i]; }
|
||||
MockFormat.key = k;
|
||||
return MockFormat;
|
||||
});
|
||||
provider = new FormatProvider(mockFormats);
|
||||
provider = new FormatProvider(mockFormats, mockLog);
|
||||
});
|
||||
|
||||
it("looks up formats by key", function () {
|
||||
@ -56,6 +58,13 @@ define(
|
||||
});
|
||||
});
|
||||
|
||||
it("warns about unknown formats", function () {
|
||||
provider.getFormat('a'); // known format
|
||||
expect(mockLog.warn).not.toHaveBeenCalled();
|
||||
provider.getFormat('some-unknown-format');
|
||||
expect(mockLog.warn).toHaveBeenCalledWith(jasmine.any(String));
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -137,6 +137,13 @@ define(
|
||||
.toHaveBeenCalledWith(mockScope.structure.format);
|
||||
});
|
||||
|
||||
it("throws an error for unknown formats", function () {
|
||||
mockFormatService.getFormat.andReturn(undefined);
|
||||
expect(function () {
|
||||
fireWatch("structure.format", "some-format");
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
describe("using the obtained format", function () {
|
||||
var testValue = 1234321,
|
||||
testText = "some text";
|
||||
|
@ -34,6 +34,7 @@ define(
|
||||
describe("The TimeRangeController", function () {
|
||||
var mockScope,
|
||||
mockFormatService,
|
||||
testDefaultFormat,
|
||||
mockNow,
|
||||
mockFormat,
|
||||
controller;
|
||||
@ -63,6 +64,7 @@ define(
|
||||
"formatService",
|
||||
[ "getFormat" ]
|
||||
);
|
||||
testDefaultFormat = 'utc';
|
||||
mockFormat = jasmine.createSpyObj(
|
||||
"format",
|
||||
[ "validate", "format", "parse" ]
|
||||
@ -79,6 +81,7 @@ define(
|
||||
controller = new TimeRangeController(
|
||||
mockScope,
|
||||
mockFormatService,
|
||||
testDefaultFormat,
|
||||
mockNow
|
||||
);
|
||||
});
|
||||
@ -199,6 +202,12 @@ define(
|
||||
.toHaveBeenCalledWith('test-format');
|
||||
});
|
||||
|
||||
it("throws an error for unknown formats", function () {
|
||||
mockFormatService.getFormat.andReturn(undefined);
|
||||
expect(function () {
|
||||
fireWatch("parameters.format", "some-format");
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user