Skip to content

Instantly share code, notes, and snippets.

@dukex
Created April 27, 2011 23:45
Show Gist options
  • Save dukex/945489 to your computer and use it in GitHub Desktop.
Save dukex/945489 to your computer and use it in GitHub Desktop.
qUnit Vs Jasmine
describe("accessibility", function () {
beforeEach(function(){
var ac = $('#menu1').menu();
var item0 = $("li:eq(0) a");
});
it("should has menu class", function(){
expect(ac.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all")).toEqual(true);
});
it("should has role listbox", function(){
expect(ac.attr("role")).toEqual("listbox");
});
it("should not has aria-activedescendant", function(){
expect(ac.attr("aria-activedescendant")).not.toEqual(true)
});
it("should add aria attribute for id from dom", function(){
var item = ac.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
ac.menu( "focus", $.Event(), item );
expect( ac.attr("aria-activedescendant")).toEqual("xid");
});
it("should add aria attribute for generated id"), function(){
var item = ac.find( "li:last" );
ac.menu( "focus", $.Event(), item );
expect( ac.attr("aria-activedescendant")).toEqual("menu1-activedescendant");
});
});
test("accessibility", function () {
expect(5);
var ac = $('#menu1').menu();
var item0 = $("li:eq(0) a");
ok( ac.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
equals( ac.attr("role"), "listbox", "main role");
ok( !ac.attr("aria-activedescendant"), "aria attribute not yet active");
var item = ac.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
ac.menu( "focus", $.Event(), item );
equals( ac.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
var item = ac.find( "li:last" );
ac.menu( "focus", $.Event(), item );
equals( ac.attr("aria-activedescendant"), "menu1-activedescendant", "aria attribute, generated id");
});
@suissa
Copy link

suissa commented Apr 28, 2011

Prefiro TDD ;D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment