mirror of
https://github.com/nasa/openmct.git
synced 2025-01-25 21:59:23 +00:00
Fixed failing MCTToolbarSpec
This commit is contained in:
parent
66e827de2e
commit
a023b0e19c
@ -30,6 +30,11 @@ define(
|
|||||||
var mockScope,
|
var mockScope,
|
||||||
mctToolbar;
|
mctToolbar;
|
||||||
|
|
||||||
|
function installController() {
|
||||||
|
var Controller = mctToolbar.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 +49,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.
|
||||||
mctToolbar.controller(mockScope);
|
installController();
|
||||||
|
|
||||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||||
"mctForm",
|
"mctForm",
|
||||||
@ -56,7 +61,7 @@ define(
|
|||||||
var someState = { someKey: "some value" };
|
var someState = { someKey: "some value" };
|
||||||
mockScope.name = "someName";
|
mockScope.name = "someName";
|
||||||
|
|
||||||
mctToolbar.controller(mockScope);
|
installController();
|
||||||
|
|
||||||
mockScope.$watch.mostRecentCall.args[1](someState);
|
mockScope.$watch.mostRecentCall.args[1](someState);
|
||||||
|
|
||||||
@ -65,7 +70,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
|
||||||
mctToolbar.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 +83,7 @@ define(
|
|||||||
regExp;
|
regExp;
|
||||||
|
|
||||||
// Add getRegExp to scope
|
// Add getRegExp to scope
|
||||||
mctToolbar.controller(mockScope);
|
installController();
|
||||||
regExp = mockScope.getRegExp(strRegExp);
|
regExp = mockScope.getRegExp(strRegExp);
|
||||||
|
|
||||||
// Same object instance each time...
|
// Same object instance each time...
|
||||||
@ -91,7 +96,7 @@ define(
|
|||||||
var regExp = /^\d+[a-d]$/;
|
var regExp = /^\d+[a-d]$/;
|
||||||
|
|
||||||
// Add getRegExp to scope
|
// Add getRegExp to scope
|
||||||
mctToolbar.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 +105,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
|
||||||
mctToolbar.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/);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user