From fb317bedeb18456dc22c6187639325e350e6e9d6 Mon Sep 17 00:00:00 2001 From: Pranav Shekhar Jha <jha.pranav.s@gmail.com> Date: Wed, 20 May 2015 21:54:05 -0700 Subject: [PATCH] added tests --- test/amd-specs.js | 18 ++++++++++++++++-- test/commonjs-specs.js | 14 ++++++++++++++ test/script-tag-specs.js | 13 +++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/test/amd-specs.js b/test/amd-specs.js index db56da4..703bc17 100644 --- a/test/amd-specs.js +++ b/test/amd-specs.js @@ -1,7 +1,8 @@ define([ 'chai', - 'chaiA11y' -], function (chai, chaiA11y) { + 'chaiA11y', + 'jquery' +], function (chai, chaiA11y, $) { 'use strict'; chai.use(chaiA11y); var expect = chai.expect; @@ -29,5 +30,18 @@ define([ ] }); }); + it('should not pollute the DOM', function () { + return expect('<button id="temp_id">temp</button>').to.be.accessible().then(function () { + return expect($('#temp_id').size()).to.eql(0); + }); + }); + it('should not move or delete an existing element', function () { + var btn = $('<button id="temp_id">temp</button>'); + $('body').append($('<div id="temp_div"></div>').append(btn)); + return expect(btn).to.be.accessible().then(function () { + expect($('#temp_div > #temp_id').size()).to.eql(1); + $('#temp_id').remove(); + }); + }) }); }); \ No newline at end of file diff --git a/test/commonjs-specs.js b/test/commonjs-specs.js index 72b2dab..24ef2bd 100644 --- a/test/commonjs-specs.js +++ b/test/commonjs-specs.js @@ -1,5 +1,6 @@ 'use strict'; var chai = require('chai'); +var $ = require('jquery'); chai.use(require('../lib')); var expect = chai.expect; describe('chai a11y', function () { @@ -26,4 +27,17 @@ describe('chai a11y', function () { ] }); }); + it('should not pollute the DOM', function () { + return expect('<button id="temp_id">temp</button>').to.be.accessible().then(function () { + return expect($('#temp_id').size()).to.eql(0); + }); + }); + it('should not move or delete an existing element', function () { + var btn = $('<button id="temp_id">temp</button>'); + $('body').append($('<div id="temp_div"></div>').append(btn)); + return expect(btn).to.be.accessible().then(function () { + expect($('#temp_div > #temp_id').size()).to.eql(1); + $('#temp_id').remove(); + }); + }) }); \ No newline at end of file diff --git a/test/script-tag-specs.js b/test/script-tag-specs.js index 999a2bd..e727362 100644 --- a/test/script-tag-specs.js +++ b/test/script-tag-specs.js @@ -23,4 +23,17 @@ describe('chai a11y', function () { ] }); }); + it('should not pollute the DOM', function () { + return expect('<button id="temp_id">temp</button>').to.be.accessible().then(function () { + return expect($('#temp_id').size()).to.eql(0); + }); + }); + it('should not move or delete an existing element', function () { + var btn = $('<button id="temp_id">temp</button>'); + $('body').append($('<div id="temp_div"></div>').append(btn)); + return expect(btn).to.be.accessible().then(function () { + expect($('#temp_div > #temp_id').size()).to.eql(1); + $('#temp_id').remove(); + }); + }) }); \ No newline at end of file