[Themes] Add test cases

Add test cases to verify that stylesheets are excluded/included
according to theme, when a theme has been specified.

nasa/openmctweb#241
This commit is contained in:
Victor Woeltjen
2015-11-04 11:46:49 -08:00
parent 15f9bc083c
commit 226f0932da

View File

@@ -32,10 +32,11 @@ define(
mockPlainDocument, mockPlainDocument,
mockHead, mockHead,
mockElement, mockElement,
testBundle,
loader; loader;
beforeEach(function () { beforeEach(function () {
var testBundle = { testBundle = {
path: "a/b", path: "a/b",
resources: "c" resources: "c"
}; };
@@ -72,6 +73,40 @@ define(
expect(mockElement.setAttribute) expect(mockElement.setAttribute)
.toHaveBeenCalledWith('href', "a/b/c/d.css"); .toHaveBeenCalledWith('href', "a/b/c/d.css");
}); });
describe("for themed stylesheets", function () {
var testTheme = "test-theme";
beforeEach(function () {
testStyleSheets = [{
stylesheetUrl: "themed.css",
bundle: testBundle,
theme: testTheme
}, {
stylesheetUrl: "bad-theme.css",
bundle: testBundle,
theme: 'bad-theme'
}];
loader = new StyleSheetLoader(
testStyleSheets,
mockDocument,
testTheme
);
})
it("includes matching themes", function () {
expect(mockElement.setAttribute)
.toHaveBeenCalledWith('href', "a/b/c/themed.css");
});
it("excludes mismatching themes", function () {
expect(mockElement.setAttribute)
.not.toHaveBeenCalledWith('href', "a/b/c/bad-theme.css");
});
});
}); });
} }
); );