小编cor*_*lls的帖子

使用Jasmine测试单击事件,将样式表附加到头部

jQuery的

$(".theme-picker").click(function () {
      $('head').append('<link rel="stylesheet" href="" type="text/css" media="screen" id="theme_switcher"/>');
});
Run Code Online (Sandbox Code Playgroud)

茉莉花

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");
});
});
Run Code Online (Sandbox Code Playgroud)

我是茉莉花的新手,目前测试失败了.我不确定它是固定装置,触发器事件还是完全不同的东西.

jquery jasmine jasmine-jquery

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

jasmine ×1

jasmine-jquery ×1

jquery ×1