Skip to content

Commit

Permalink
restructure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed Aug 5, 2016
1 parent 3c14965 commit 9cf168e
Showing 1 changed file with 60 additions and 30 deletions.
90 changes: 60 additions & 30 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,67 +122,97 @@ describe('Basic', function() {
});
});

describe('ShadowDOM v0', function() {
if (!Element.prototype.createShadowRoot) {
console.log('ShadowDOM v0 is not supported by the browser.');
return;
}
let fixture, host;

if (!document.createElement('div').createShadowRoot) {
console.log('ShadowDOM v0 is not supported by the browser.');
} else {
it('should apply inside shadow trees', function() {
const fixture = document.querySelector('#fixture');
beforeEach(function() {
fixture = document.querySelector('#fixture');
fixture.inert = false;
const host = document.createElement('div');
host = document.createElement('div');
fixture.appendChild(host);
const shadowRoot = host.createShadowRoot();
host.createShadowRoot();
});

afterEach(function() {
fixture.removeChild(host);
});

it('should apply inside shadow trees', function() {
const shadowButton = document.createElement('button');
shadowButton.textContent = 'Shadow button';
shadowRoot.appendChild(shadowButton);
host.shadowRoot.appendChild(shadowButton);
fixture.inert = true;
expect(isUnfocusable(shadowButton)).to.equal(true);
});

it('should apply inert styles inside shadow trees', function() {
const fixture = document.querySelector('#fixture');
const host = document.createElement('div');
fixture.appendChild(host);
const shadowRoot = host.createShadowRoot();
const shadowButton = document.createElement('button');
shadowButton.textContent = 'Shadow button';
shadowRoot.appendChild(shadowButton);
host.shadowRoot.appendChild(shadowButton);
shadowButton.inert = true;
expect(getComputedStyle(shadowButton).pointerEvents).to.equal('none');
});

it('should apply inside shadow trees distributed content (ShadowDOM v0)', function() {
const fixture = document.querySelector('#fixture');
fixture.inert = false;
const host = document.createElement('div');
fixture.appendChild(host);
const shadowRoot = host.createShadowRoot();
shadowRoot.appendChild(document.createElement('content'));
it('should apply inside shadow trees distributed content', function() {
host.shadowRoot.appendChild(document.createElement('content'));
const distributedButton = document.createElement('button');
distributedButton.textContent = 'Distributed button';
host.appendChild(distributedButton);
fixture.inert = true;
expect(isUnfocusable(distributedButton)).to.equal(true);
});
}
});

describe('ShadowDOM v1', function() {
if (!Element.prototype.attachShadow) {
console.log('ShadowDOM v1 is not supported by the browser.');
return;
}
let fixture, host;

if (!document.createElement('div').attachShadow) {
console.log('ShadowDOM v1 is not supported by the browser.');
} else {
it('should apply inside shadow trees distributed content (ShadowDOM v1)', function() {
const fixture = document.querySelector('#fixture');
beforeEach(function() {
fixture = document.querySelector('#fixture');
fixture.inert = false;
const host = document.createElement('div');
host = document.createElement('div');
fixture.appendChild(host);
const shadowRoot = host.attachShadow({mode: 'open'});
shadowRoot.appendChild(document.createElement('slot'));
host.attachShadow({
mode: 'open'
});
});

afterEach(function() {
fixture.removeChild(host);
});

it('should apply inside shadow trees', function() {
const shadowButton = document.createElement('button');
shadowButton.textContent = 'Shadow button';
host.shadowRoot.appendChild(shadowButton);
fixture.inert = true;
expect(isUnfocusable(shadowButton)).to.equal(true);
});

it('should apply inert styles inside shadow trees', function() {
const shadowButton = document.createElement('button');
shadowButton.textContent = 'Shadow button';
host.shadowRoot.appendChild(shadowButton);
shadowButton.inert = true;
expect(getComputedStyle(shadowButton).pointerEvents).to.equal('none');
});

it('should apply inside shadow trees distributed content', function() {
host.shadowRoot.appendChild(document.createElement('slot'));
const distributedButton = document.createElement('button');
distributedButton.textContent = 'Distributed button';
host.appendChild(distributedButton);
fixture.inert = true;
expect(isUnfocusable(distributedButton)).to.equal(true);
});
}
});
});

describe('nested inert regions', function() {
Expand Down

0 comments on commit 9cf168e

Please sign in to comment.