Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Test branch for testing gulp-web-component-tester integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Aug 21, 2014
1 parent ee67311 commit 848e0da
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"dependencies": {
"polymer": "Polymer/polymer#master",
"core-selection": "Polymer/core-selection#master"
},
"devDependencies": {
"polymer-test-tools": "Polymer/polymer-test-tools#master"
}
}
2 changes: 2 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var gulp = require('gulp');
require('gulp-web-component-tester').init(gulp);
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"gulp": "^3.8.7"
}
}
62 changes: 62 additions & 0 deletions tests/html/core-list-basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-list</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../../platform/platform.js"></script>
<link rel="import" href="../../../polymer-test-tools/ci-tools.html">
<link rel="import" href="../../core-list.html">
<style>
html, body {
margin: 0;
-webkit-tap-highlight-color: transparent;
overflow: hidden;
}
core-list {
display: block;
height: 100%;
margin: 0 auto;
}
</style>
</head>
<body fit>

<core-list id="list">
<template>
<div class="item {{ {selected: selected} | tokenList }}">
<div class="subject">Row: {{index}}, Record ID: {{model.id}}</div>
<input type="checkbox" checked="{{model.checked}}">
<input type="number" value="{{model.value}}" class="narrow">
<select selectedIndex="{{model.type}}"><option>a</option><option>b</option><option>c</option></select>
</div>
</template>
</core-list>

<script>
document.addEventListener('polymer-ready', function() {
// Test a property
var el = document.querySelector('core-list');
el.data = [
{id:123, checked:true, value:99, type:1},
{id:456, checked:false, value:88, type:2}
];
el.onMutation(el, function() {
chai.assert(el.children.length == el.data.length + 1,
'children.length should be 1 (template) + count of data elements');
done();
});

});

</script>

</body>
</html>
67 changes: 67 additions & 0 deletions tests/html/core-list-delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-list</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../../platform/platform.js"></script>
<link rel="import" href="../../../polymer-test-tools/ci-tools.html">
<link rel="import" href="../../core-list.html">
<style>
html, body {
margin: 0;
-webkit-tap-highlight-color: transparent;
overflow: hidden;
}
core-list {
display: block;
height: 100%;
margin: 0 auto;
}
</style>
</head>
<body fit>

<core-list id="list">
<template>
<div class="item {{ {selected: selected} | tokenList }}">
<div class="subject">Row: {{index}}, Record ID: {{model.id}}</div>
<input type="checkbox" checked="{{model.checked}}">
<input type="number" value="{{model.value}}" class="narrow">
<select selectedIndex="{{model.type}}"><option>a</option><option>b</option><option>c</option></select>
</div>
</template>
</core-list>

<script>
document.addEventListener('polymer-ready', function() {
// Test a property
var el = document.querySelector('core-list');
el.data = [
{id:123, checked:true, value:99, type:1},
{id:456, checked:false, value:88, type:2}
];
el.onMutation(el, function() {
el.data.length = 1;
requestAnimationFrame(function() {
chai.assert(el.children.length == 2 + 1,
'children.length should be 1 (template) + count of data elements');
chai.assert(el.children[el.children.length-1].getAttribute('hidden') !== null,
'last element shoudl be hidden');
done();
});
});

});

</script>

</body>
</html>
4 changes: 4 additions & 0 deletions tests/js/htmltests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
htmlSuite('core-list', function() {
htmlTest('html/core-list-basic.html');
htmlTest('html/core-list-delete.html');
});
14 changes: 14 additions & 0 deletions tests/runner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype htmlz>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Web Component Test Runner</title>
<script src="../../polymer-test-tools/ci-support.js"></script>
</head>
<body>
<script>
runTests('tests.json');
</script>
</body>
</html>
6 changes: 6 additions & 0 deletions tests/tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tools": ["chai", "mocha-tdd"],
"tests": [
"js/htmltests.js"
]
}

0 comments on commit 848e0da

Please sign in to comment.