jQuery
$(".theme-picker").click(function () {
$('head').append('<link rel="stylesheet" href="" type="text/css" media="screen" id="theme_switcher"/>');
});
Jasmine
describe("style.switcher", function() {
beforeEach( function() {
jasmine.getFixtures().set(
'<head></head>' +
'<div class="switcher">' +
'<a class="theme-picker" title="theme-picker"></a>' +
'<a class="folder-picker" title="folder-picker"></a>' +
'<a class="font-picker" title="font-picker"></a>' +
'<a class="color-picker" title="color-picker"></a>' +
'</div>' );
});
it("loads themes switcher link in head", function() {
$('.theme-picker').trigger('click');
expect( $('head') ).toContain("theme_switcher");
});
});
I am new to jasmine and the test is currently failing. I am unsure if it is the fixture, the trigger event or something else entirely.
toContain()
could take a CSS selector as an argument. Do you have a reference you could link to? – Science