[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:
@@ -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");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user