mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 12:03:21 +00:00
[API Refactor] Update failing specs
This commit is contained in:
parent
65c0cc66b6
commit
df631ba40e
@ -30,6 +30,12 @@ define(
|
|||||||
var mockScope,
|
var mockScope,
|
||||||
mctForm;
|
mctForm;
|
||||||
|
|
||||||
|
function installController() {
|
||||||
|
var controllerProperty = mctForm.controller,
|
||||||
|
Controller = mctForm.controller[1];
|
||||||
|
return new Controller(mockScope);
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]);
|
mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]);
|
||||||
mockScope.$parent = {};
|
mockScope.$parent = {};
|
||||||
@ -44,7 +50,7 @@ define(
|
|||||||
// mct-form needs to watch for the form by name
|
// mct-form needs to watch for the form by name
|
||||||
// in order to convey changes in $valid, $dirty, etc
|
// in order to convey changes in $valid, $dirty, etc
|
||||||
// up to the parent scope.
|
// up to the parent scope.
|
||||||
mctForm.controller(mockScope);
|
installController();
|
||||||
|
|
||||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||||
"mctForm",
|
"mctForm",
|
||||||
@ -56,7 +62,7 @@ define(
|
|||||||
var someState = { someKey: "some value" };
|
var someState = { someKey: "some value" };
|
||||||
mockScope.name = "someName";
|
mockScope.name = "someName";
|
||||||
|
|
||||||
mctForm.controller(mockScope);
|
installController();
|
||||||
|
|
||||||
mockScope.$watch.mostRecentCall.args[1](someState);
|
mockScope.$watch.mostRecentCall.args[1](someState);
|
||||||
|
|
||||||
@ -65,7 +71,7 @@ define(
|
|||||||
|
|
||||||
it("allows strings to be converted to RegExps", function () {
|
it("allows strings to be converted to RegExps", function () {
|
||||||
// This is needed to support ng-pattern in the template
|
// This is needed to support ng-pattern in the template
|
||||||
mctForm.controller(mockScope);
|
installController();
|
||||||
|
|
||||||
// Should have added getRegExp to the scope,
|
// Should have added getRegExp to the scope,
|
||||||
// to convert strings to regular expressions
|
// to convert strings to regular expressions
|
||||||
@ -78,7 +84,7 @@ define(
|
|||||||
regExp;
|
regExp;
|
||||||
|
|
||||||
// Add getRegExp to scope
|
// Add getRegExp to scope
|
||||||
mctForm.controller(mockScope);
|
installController();
|
||||||
regExp = mockScope.getRegExp(strRegExp);
|
regExp = mockScope.getRegExp(strRegExp);
|
||||||
|
|
||||||
// Same object instance each time...
|
// Same object instance each time...
|
||||||
@ -91,7 +97,7 @@ define(
|
|||||||
var regExp = /^\d+[a-d]$/;
|
var regExp = /^\d+[a-d]$/;
|
||||||
|
|
||||||
// Add getRegExp to scope
|
// Add getRegExp to scope
|
||||||
mctForm.controller(mockScope);
|
installController();
|
||||||
|
|
||||||
// Should have added getRegExp to the scope,
|
// Should have added getRegExp to the scope,
|
||||||
// to convert strings to regular expressions
|
// to convert strings to regular expressions
|
||||||
@ -100,7 +106,7 @@ define(
|
|||||||
|
|
||||||
it("passes a non-whitespace regexp when no pattern is defined", function () {
|
it("passes a non-whitespace regexp when no pattern is defined", function () {
|
||||||
// If no pattern is supplied, ng-pattern should match anything
|
// If no pattern is supplied, ng-pattern should match anything
|
||||||
mctForm.controller(mockScope);
|
installController();
|
||||||
expect(mockScope.getRegExp()).toEqual(/\S/);
|
expect(mockScope.getRegExp()).toEqual(/\S/);
|
||||||
expect(mockScope.getRegExp(undefined)).toEqual(/\S/);
|
expect(mockScope.getRegExp(undefined)).toEqual(/\S/);
|
||||||
});
|
});
|
||||||
|
@ -37,7 +37,6 @@ define(
|
|||||||
describe("The logging level handler", function () {
|
describe("The logging level handler", function () {
|
||||||
var mockLog,
|
var mockLog,
|
||||||
mockApp,
|
mockApp,
|
||||||
mockProvide,
|
|
||||||
mockDelegate,
|
mockDelegate,
|
||||||
mockMethods;
|
mockMethods;
|
||||||
|
|
||||||
@ -61,8 +60,7 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockMethods = jasmine.createSpyObj("levels", LOG_METHODS);
|
mockMethods = jasmine.createSpyObj("levels", LOG_METHODS);
|
||||||
mockLog = jasmine.createSpyObj('$log', LOG_METHODS);
|
mockLog = jasmine.createSpyObj('$log', LOG_METHODS);
|
||||||
mockApp = jasmine.createSpyObj('app', ['config']);
|
mockApp = jasmine.createSpyObj('app', ['config', 'decorator']);
|
||||||
mockProvide = jasmine.createSpyObj('$provide', ['decorator']);
|
|
||||||
mockDelegate = jasmine.createSpyObj('$delegate', LOG_METHODS);
|
mockDelegate = jasmine.createSpyObj('$delegate', LOG_METHODS);
|
||||||
|
|
||||||
LOG_METHODS.forEach(function (m) {
|
LOG_METHODS.forEach(function (m) {
|
||||||
@ -70,14 +68,11 @@ define(
|
|||||||
mockDelegate[m].andCallFake(mockMethods[m]);
|
mockDelegate[m].andCallFake(mockMethods[m]);
|
||||||
});
|
});
|
||||||
|
|
||||||
mockApp.config.andCallFake(function (callback) {
|
mockApp.decorator.andCallFake(function (key, decoration) {
|
||||||
callback(mockProvide);
|
// We only expect $log to be decorated
|
||||||
});
|
if (key === '$log' && decoration[0] === '$delegate') {
|
||||||
|
decoration[1](mockDelegate);
|
||||||
mockProvide.decorator.andCallFake(function (key, callback) {
|
}
|
||||||
// Only $log should be configured in any case
|
|
||||||
expect(key).toEqual('$log');
|
|
||||||
callback(mockDelegate);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ define(
|
|||||||
mockCallback,
|
mockCallback,
|
||||||
mockHttp,
|
mockHttp,
|
||||||
mockLog,
|
mockLog,
|
||||||
|
mockRegistry,
|
||||||
testBundles;
|
testBundles;
|
||||||
|
|
||||||
// Used to wait for then-chain resolution;
|
// Used to wait for then-chain resolution;
|
||||||
@ -53,7 +54,13 @@ define(
|
|||||||
mockCallback = jasmine.createSpy("callback");
|
mockCallback = jasmine.createSpy("callback");
|
||||||
mockHttp = jasmine.createSpyObj("$http", ["get"]);
|
mockHttp = jasmine.createSpyObj("$http", ["get"]);
|
||||||
mockLog = jasmine.createSpyObj("$log", ["error", "warn", "info", "debug"]);
|
mockLog = jasmine.createSpyObj("$log", ["error", "warn", "info", "debug"]);
|
||||||
loader = new BundleLoader(mockHttp, mockLog);
|
mockRegistry = jasmine.createSpyObj(
|
||||||
|
'legacyRegistry',
|
||||||
|
[ 'list', 'contains', 'get' ]
|
||||||
|
);
|
||||||
|
mockRegistry.list.andReturn([]);
|
||||||
|
mockRegistry.contains.andReturn(false);
|
||||||
|
loader = new BundleLoader(mockHttp, mockLog, mockRegistry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("accepts a JSON file name and loads all bundles", function () {
|
it("accepts a JSON file name and loads all bundles", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user