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

Commit 848e0da

Browse files
committed
Test branch for testing gulp-web-component-tester integration.
1 parent ee67311 commit 848e0da

9 files changed

+164
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

bower.json

+3
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
"dependencies": {
55
"polymer": "Polymer/polymer#master",
66
"core-selection": "Polymer/core-selection#master"
7+
},
8+
"devDependencies": {
9+
"polymer-test-tools": "Polymer/polymer-test-tools#master"
710
}
811
}

gulpfile.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var gulp = require('gulp');
2+
require('gulp-web-component-tester').init(gulp);

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"gulp": "^3.8.7"
4+
}
5+
}

tests/html/core-list-basic.html

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!doctype html>
2+
<!--
3+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7+
Code distributed by Google as part of the polymer project is also
8+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9+
-->
10+
<html>
11+
<head>
12+
<title>core-list</title>
13+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
14+
<script src="../../../platform/platform.js"></script>
15+
<link rel="import" href="../../../polymer-test-tools/ci-tools.html">
16+
<link rel="import" href="../../core-list.html">
17+
<style>
18+
html, body {
19+
margin: 0;
20+
-webkit-tap-highlight-color: transparent;
21+
overflow: hidden;
22+
}
23+
core-list {
24+
display: block;
25+
height: 100%;
26+
margin: 0 auto;
27+
}
28+
</style>
29+
</head>
30+
<body fit>
31+
32+
<core-list id="list">
33+
<template>
34+
<div class="item {{ {selected: selected} | tokenList }}">
35+
<div class="subject">Row: {{index}}, Record ID: {{model.id}}</div>
36+
<input type="checkbox" checked="{{model.checked}}">
37+
<input type="number" value="{{model.value}}" class="narrow">
38+
<select selectedIndex="{{model.type}}"><option>a</option><option>b</option><option>c</option></select>
39+
</div>
40+
</template>
41+
</core-list>
42+
43+
<script>
44+
document.addEventListener('polymer-ready', function() {
45+
// Test a property
46+
var el = document.querySelector('core-list');
47+
el.data = [
48+
{id:123, checked:true, value:99, type:1},
49+
{id:456, checked:false, value:88, type:2}
50+
];
51+
el.onMutation(el, function() {
52+
chai.assert(el.children.length == el.data.length + 1,
53+
'children.length should be 1 (template) + count of data elements');
54+
done();
55+
});
56+
57+
});
58+
59+
</script>
60+
61+
</body>
62+
</html>

tests/html/core-list-delete.html

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!doctype html>
2+
<!--
3+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7+
Code distributed by Google as part of the polymer project is also
8+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9+
-->
10+
<html>
11+
<head>
12+
<title>core-list</title>
13+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
14+
<script src="../../../platform/platform.js"></script>
15+
<link rel="import" href="../../../polymer-test-tools/ci-tools.html">
16+
<link rel="import" href="../../core-list.html">
17+
<style>
18+
html, body {
19+
margin: 0;
20+
-webkit-tap-highlight-color: transparent;
21+
overflow: hidden;
22+
}
23+
core-list {
24+
display: block;
25+
height: 100%;
26+
margin: 0 auto;
27+
}
28+
</style>
29+
</head>
30+
<body fit>
31+
32+
<core-list id="list">
33+
<template>
34+
<div class="item {{ {selected: selected} | tokenList }}">
35+
<div class="subject">Row: {{index}}, Record ID: {{model.id}}</div>
36+
<input type="checkbox" checked="{{model.checked}}">
37+
<input type="number" value="{{model.value}}" class="narrow">
38+
<select selectedIndex="{{model.type}}"><option>a</option><option>b</option><option>c</option></select>
39+
</div>
40+
</template>
41+
</core-list>
42+
43+
<script>
44+
document.addEventListener('polymer-ready', function() {
45+
// Test a property
46+
var el = document.querySelector('core-list');
47+
el.data = [
48+
{id:123, checked:true, value:99, type:1},
49+
{id:456, checked:false, value:88, type:2}
50+
];
51+
el.onMutation(el, function() {
52+
el.data.length = 1;
53+
requestAnimationFrame(function() {
54+
chai.assert(el.children.length == 2 + 1,
55+
'children.length should be 1 (template) + count of data elements');
56+
chai.assert(el.children[el.children.length-1].getAttribute('hidden') !== null,
57+
'last element shoudl be hidden');
58+
done();
59+
});
60+
});
61+
62+
});
63+
64+
</script>
65+
66+
</body>
67+
</html>

tests/js/htmltests.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
htmlSuite('core-list', function() {
2+
htmlTest('html/core-list-basic.html');
3+
htmlTest('html/core-list-delete.html');
4+
});

tests/runner.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype htmlz>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
6+
<title>Web Component Test Runner</title>
7+
<script src="../../polymer-test-tools/ci-support.js"></script>
8+
</head>
9+
<body>
10+
<script>
11+
runTests('tests.json');
12+
</script>
13+
</body>
14+
</html>

tests/tests.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"tools": ["chai", "mocha-tdd"],
3+
"tests": [
4+
"js/htmltests.js"
5+
]
6+
}

0 commit comments

Comments
 (0)