blob: b342cfd172da24388d42a07d38f8629a52a9d332 [file] [log] [blame]
<!doctype html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<title>disabled-state</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="test-elements.html">
</head>
<body>
<test-fixture id="TrivialDisabledState">
<template>
<test-control></test-control>
</template>
</test-fixture>
<test-fixture id="InitiallyDisabledState">
<template>
<test-control disabled></test-control>
</template>
</test-fixture>
<script>
suite('disabled-state', function() {
var disableTarget;
suite('a trivial disabled state', function() {
setup(function() {
disableTarget = fixture('TrivialDisabledState');
});
suite('when disabled is true', function() {
test('receives a disabled attribute', function() {
disableTarget.disabled = true;
expect(disableTarget.hasAttribute('disabled')).to.be.eql(true);
});
test('receives an appropriate aria attribute', function() {
disableTarget.disabled = true;
expect(disableTarget.getAttribute('aria-disabled')).to.be.eql('true');
});
});
suite('when disabled is false', function() {
test('loses the disabled attribute', function() {
disableTarget.disabled = true;
expect(disableTarget.hasAttribute('disabled')).to.be.eql(true);
disableTarget.disabled = false;
expect(disableTarget.hasAttribute('disabled')).to.be.eql(false);
});
});
});
suite('a state with an initially disabled target', function() {
setup(function() {
disableTarget = fixture('InitiallyDisabledState');
});
test('preserves the disabled attribute on target', function() {
expect(disableTarget.hasAttribute('disabled')).to.be.eql(true);
expect(disableTarget.disabled).to.be.eql(true);
});
test('adds `aria-disabled` to the target', function() {
expect(disableTarget.getAttribute('aria-disabled')).to.be.eql('true');
});
});
});
</script>
</body>
</html>