Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from PolymerElements/test-no-iconset
Browse files Browse the repository at this point in the history
Test cases where there is no icon source.
  • Loading branch information
cdata committed Apr 17, 2015
2 parents 9bcf449 + 6d632f0 commit 7a7c92b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test-fixture": "polymerelements/test-fixture#^0.8.0",
"iron-iconset": "polymerelements/iron-iconset#^0.8.0",
"core-icons": "polymerelements/iron-icons#^0.8.0",
"iron-doc-viewer": "polymerelements/iron-doc-viewer",
"iron-doc-viewer": "polymerelements/iron-doc-viewer#^0.8.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.6.0",
"web-component-tester": "~2.2.6"
}
Expand Down
33 changes: 24 additions & 9 deletions test/iron-icon.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
</template>
</test-fixture>

<test-fixture id="WithoutAnIconSource">
<template>
<iron-icon icon=""></iron-icon>
<iron-icon></iron-icon>
<iron-icon src=""></iron-icon>
</template>
</test-fixture>

<script>
function iconElementFor (node) {
var nodes = Polymer.dom(node.root).childNodes;
Expand All @@ -54,40 +62,40 @@
return /png/.test(node.style.backgroundImage);
}

suite('<iron-icon>', function () {
suite('basic behavior', function () {
suite('<iron-icon>', function() {
suite('basic behavior', function() {
var icon;

setup(function () {
setup(function() {
icon = fixture('TrivialIcon');
});

test('can be assigned an icon with the src attribute', function () {
test('can be assigned an icon with the src attribute', function() {
expect(iconElementFor(icon)).to.be.ok;
expect(iconElementFor(icon).src).to.match(/demo\/location\.png/);
});

test('can change its src dynamically', function () {
test('can change its src dynamically', function() {
icon.src = 'foo.png';

expect(iconElementFor(icon).src).to.match(/foo\.png/);
});
});

suite('when paired with an iconset', function () {
suite('when paired with an iconset', function() {
var icon;

setup(function () {
setup(function() {
var elements = fixture('IconFromIconset');

icon = elements[1];
});

test('can be assigned an icon from the iconset', function () {
test('can be assigned an icon from the iconset', function() {
expect(hasIcon(icon)).to.be.ok;
});

test('can change its icon dynamically', function () {
test('can change its icon dynamically', function() {
var style = icon.style;

expect(style.backgroundPositionX).to.be.eql('0px');
Expand All @@ -97,6 +105,13 @@
expect(style.backgroundPositionX).to.be.eql('-24px');
});
});

suite('when no icon source is provided', function() {
test('will politely wait for an icon source without throwing', function() {
document.createElement('iron-icon');
fixture('WithoutAnIconSource');
});
})
});
</script>

Expand Down

0 comments on commit 7a7c92b

Please sign in to comment.