mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 09:52:04 +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 () {
|
describe("The FormatProvider", function () {
|
||||||
var mockFormats,
|
var mockFormats,
|
||||||
|
mockLog,
|
||||||
mockFormatInstances,
|
mockFormatInstances,
|
||||||
provider;
|
provider;
|
||||||
|
|
||||||
@ -40,13 +41,14 @@ define(
|
|||||||
[ 'parse', 'validate', 'format' ]
|
[ 'parse', 'validate', 'format' ]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
mockLog = jasmine.createSpyObj('$log', ['error', 'warn']);
|
||||||
// Return constructors
|
// Return constructors
|
||||||
mockFormats = KEYS.map(function (k, i) {
|
mockFormats = KEYS.map(function (k, i) {
|
||||||
function MockFormat() { return mockFormatInstances[i]; }
|
function MockFormat() { return mockFormatInstances[i]; }
|
||||||
MockFormat.key = k;
|
MockFormat.key = k;
|
||||||
return MockFormat;
|
return MockFormat;
|
||||||
});
|
});
|
||||||
provider = new FormatProvider(mockFormats);
|
provider = new FormatProvider(mockFormats, mockLog);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("looks up formats by key", function () {
|
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);
|
.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 () {
|
describe("using the obtained format", function () {
|
||||||
var testValue = 1234321,
|
var testValue = 1234321,
|
||||||
testText = "some text";
|
testText = "some text";
|
||||||
|
@ -34,6 +34,7 @@ define(
|
|||||||
describe("The TimeRangeController", function () {
|
describe("The TimeRangeController", function () {
|
||||||
var mockScope,
|
var mockScope,
|
||||||
mockFormatService,
|
mockFormatService,
|
||||||
|
testDefaultFormat,
|
||||||
mockNow,
|
mockNow,
|
||||||
mockFormat,
|
mockFormat,
|
||||||
controller;
|
controller;
|
||||||
@ -63,6 +64,7 @@ define(
|
|||||||
"formatService",
|
"formatService",
|
||||||
[ "getFormat" ]
|
[ "getFormat" ]
|
||||||
);
|
);
|
||||||
|
testDefaultFormat = 'utc';
|
||||||
mockFormat = jasmine.createSpyObj(
|
mockFormat = jasmine.createSpyObj(
|
||||||
"format",
|
"format",
|
||||||
[ "validate", "format", "parse" ]
|
[ "validate", "format", "parse" ]
|
||||||
@ -79,6 +81,7 @@ define(
|
|||||||
controller = new TimeRangeController(
|
controller = new TimeRangeController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockFormatService,
|
mockFormatService,
|
||||||
|
testDefaultFormat,
|
||||||
mockNow
|
mockNow
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -199,6 +202,12 @@ define(
|
|||||||
.toHaveBeenCalledWith('test-format');
|
.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