mirror of
https://github.com/nasa/openmct.git
synced 2025-01-18 18:57:01 +00:00
[Imagery] Test mct-background-image filters
This commit is contained in:
parent
2f5dc8a887
commit
2dfde9a612
@ -35,7 +35,10 @@ define(
|
||||
mockDocument = [
|
||||
jasmine.createSpyObj('document', ['createElement'])
|
||||
];
|
||||
mockScope = jasmine.createSpyObj('scope', ['$watch']);
|
||||
mockScope = jasmine.createSpyObj('scope', [
|
||||
'$watch',
|
||||
'$watchCollection'
|
||||
]);
|
||||
mockElement = jasmine.createSpyObj('element', ['css']);
|
||||
testImage = {};
|
||||
|
||||
@ -52,8 +55,12 @@ define(
|
||||
expect(directive.scope.mctBackgroundImage).toEqual("=");
|
||||
});
|
||||
|
||||
it("watches for changes to the URL", function () {
|
||||
describe("once linked", function () {
|
||||
beforeEach(function () {
|
||||
directive.link(mockScope, mockElement, {});
|
||||
});
|
||||
|
||||
it("watches for changes to the URL", function () {
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
'mctBackgroundImage',
|
||||
jasmine.any(Function)
|
||||
@ -63,8 +70,6 @@ define(
|
||||
it("updates images in-order, even when they load out-of-order", function () {
|
||||
var firstOnload;
|
||||
|
||||
directive.link(mockScope, mockElement);
|
||||
|
||||
mockScope.$watch.mostRecentCall.args[1]("some/url/0");
|
||||
firstOnload = testImage.onload;
|
||||
|
||||
@ -82,8 +87,6 @@ define(
|
||||
});
|
||||
|
||||
it("clears the background image when undefined is passed in", function () {
|
||||
directive.link(mockScope, mockElement);
|
||||
|
||||
mockScope.$watch.mostRecentCall.args[1]("some/url/0");
|
||||
testImage.onload();
|
||||
mockScope.$watch.mostRecentCall.args[1](undefined);
|
||||
@ -93,6 +96,30 @@ define(
|
||||
"none"
|
||||
]);
|
||||
});
|
||||
|
||||
it("updates filters on change", function () {
|
||||
var filters = { brightness: 123, contrast: 21 };
|
||||
mockScope.$watchCollection.calls.forEach(function (call) {
|
||||
if (call.args[0] === 'filters') {
|
||||
call.args[1](filters);
|
||||
}
|
||||
});
|
||||
expect(mockElement.css).toHaveBeenCalledWith(
|
||||
'filter',
|
||||
'brightness(123%) contrast(21%)'
|
||||
);
|
||||
});
|
||||
|
||||
it("clears filters when none are present", function () {
|
||||
mockScope.$watchCollection.calls.forEach(function (call) {
|
||||
if (call.args[0] === 'filters') {
|
||||
call.args[1](undefined);
|
||||
}
|
||||
});
|
||||
expect(mockElement.css)
|
||||
.toHaveBeenCalledWith('filter', '');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user