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

Commit

Permalink
Update tests to latest web-component-tester.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Sep 26, 2014
1 parent 7c6d6eb commit e1a0e5d
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 47 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"core-selection": "Polymer/core-selection#master"
},
"devDependencies": {
"polymer-test-tools": "Polymer/polymer-test-tools#wc-tester"
"web-component-tester": "Polymer/web-component-tester#master"
}
}
2 changes: 1 addition & 1 deletion core-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
`core-list` element represents the dom to create for each list item. The
`data` property specifies an array of list item data. The `height` property
represents the fixed height of a list item (variable height list items are
not supported).
not yet supported).
`core-list` manages a viewport of data based on the current scroll position.
For performance reasons, not every item in the list is rendered at once.
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var gulp = require('gulp');
require('gulp-web-component-tester').init(gulp);
require('web-component-tester').gulp.init(gulp);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dependencies": {
"gulp": "^3.8.7"
"devDependencies": {
"gulp": "^3.8.7",
"web-component-tester": "Polymer/web-component-tester#master"
}
}
33 changes: 19 additions & 14 deletions tests/html/core-list-basic.html → test/core-list-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
<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>
<script src="../../../polymer-test-tools/chai/chai.js"></script>
<script src="../../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-list.html">
<script src="../../platform/platform.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-list.html">
<style>
body {
margin: 0;
Expand Down Expand Up @@ -52,11 +51,12 @@
</core-list>

<script>
document.addEventListener('polymer-ready', function() {
test('core-list-basic', function(done) {
// Initial setup
var list = document.querySelector('core-list');
var physicalCount = Math.ceil(list.offsetHeight / list.height);
var index = 0;
var item;
// Helper to create random items
var generateItem = function() {
return {
Expand Down Expand Up @@ -95,7 +95,7 @@
checkTopItem('when scrolled to item ' + index);
}, next);
};
asyncSeries([
async.series([
// Initialize list with two items
function(next) {
list.data = [
Expand All @@ -110,8 +110,13 @@
},
// Select first item
function(next) {
var item = document.elementFromPoint(list.clientWidth-50, 0);
item.dispatchEvent(new MouseEvent('tap', {'view': window, 'bubbles': true}));
waitFor(function() {
var item = document.elementFromPoint(list.clientWidth-50, 0);
chai.assert(item, 'item should exist at top of list');
item.dispatchEvent(new MouseEvent('tap', {'view': window, 'bubbles': true}));
}, next);
},
function(next) {
waitFor(function() {
chai.assert(list.selection && list.selection.id == list.data[0].id,
'first item should be selected; selected id was ' + list.selection && list.selection.id);
Expand Down Expand Up @@ -233,7 +238,7 @@
// Scroll all the way to bottom
function(next) {
list.scrollTop = 99999999;
index = list.data.length - 1 - Math.floor(list.offsetHeight / list.height);
index = list.data.length - Math.ceil(list.offsetHeight / list.height);
waitFor(function() {
checkTopItem('at bottom of list');
}, next);
Expand All @@ -253,7 +258,7 @@
function(next) {
list.data.length = list.data.length - 1;
var lastIndex = index;
index = list.data.length - 1 - Math.floor(list.offsetHeight / list.height);
index = list.data.length - Math.ceil(list.offsetHeight / list.height);
waitFor(function() {
checkTopItem('at bottom of list after deleting one item from end of list');
chai.assert(list.selection.length === 1,
Expand All @@ -266,25 +271,25 @@
function(next) {
list.data.length = list.data.length - Math.floor(list.data.length/2);
var lastIndex = index;
index = list.data.length - 1 - Math.floor(list.offsetHeight / list.height);
index = list.data.length - Math.ceil(list.offsetHeight / list.height);
waitFor(function() {
checkTopItem('at bottom of list after deleting half of items items from end of list');
chai.assert(list.selection.length === 0,
'selection length should be 0');
}, next);
}, next, 32, 100000000);
},
// Delete from top
function(next) {
list.data.splice(0, Math.floor(list.data.length/2));
index = list.data.length - 1 - Math.floor(list.offsetHeight / list.height);
index = list.data.length - Math.ceil(list.offsetHeight / list.height);
waitFor(function() {
checkTopItem('at bottom of list after deleting half of items items from top of list');
}, next);
},
// Delete from top
function(next) {
list.data.splice(0, Math.floor(list.data.length/2));
index = list.data.length - 1 - Math.floor(list.offsetHeight / list.height);
index = list.data.length - Math.ceil(list.offsetHeight / list.height);
waitFor(function() {
checkTopItem('at bottom of list after deleting half of items items from top of list (again)');
}, next);
Expand Down
11 changes: 5 additions & 6 deletions tests/html/core-list-data.html → test/core-list-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
<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>
<script src="../../../polymer-test-tools/chai/chai.js"></script>
<script src="../../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-list.html">
<script src="../../platform/platform.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-list.html">
<style>
body {
margin: 0;
Expand Down Expand Up @@ -52,7 +51,7 @@
</core-list>

<script>
document.addEventListener('polymer-ready', function() {
test('core-list-data', function(done) {
// Initial setup
var list = document.querySelector('core-list');
var physicalCount = Math.ceil(list.offsetHeight / list.height);
Expand Down Expand Up @@ -82,7 +81,7 @@
}
}, next);
};
asyncSeries([
async.series([
// Set data to null
function(next) {
populateList(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
<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>
<script src="../../../polymer-test-tools/chai/chai.js"></script>
<script src="../../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-list.html">
<script src="../../platform/platform.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-list.html">
<style>
body {
margin: 0;
Expand Down Expand Up @@ -52,11 +51,12 @@
</core-list>

<script>
document.addEventListener('polymer-ready', function() {
test('core-list-selection', function(done) {
// Initial setup
var list = document.querySelector('core-list');
var physicalCount = Math.ceil(list.offsetHeight / list.height);
var index = 0;
var item;
// Helper to create random items
var generateItem = function() {
return {
Expand All @@ -66,7 +66,7 @@
type: Math.floor(Math.random()*3)
};
};
asyncSeries([
async.series([
// Add many more than viewport
function(next) {
var more = physicalCount * 20;
Expand All @@ -81,8 +81,13 @@
},
// Select first item via tap
function(next) {
var item = document.elementFromPoint(list.clientWidth-50, 0 * list.height);
item.dispatchEvent(new MouseEvent('tap', {'view': window, 'bubbles': true}));
waitFor(function() {
item = document.elementFromPoint(list.clientWidth-50, 0 * list.height);
chai.assert(item, 'item should exist at top of list');
item.dispatchEvent(new MouseEvent('tap', {'view': window, 'bubbles': true}));
}, next);
},
function(next) {
waitFor(function() {
chai.assert(list.selection && list.selection == list.data[0],
'first item should be selected; selected id was ' + list.selection && list.selection.id);
Expand Down Expand Up @@ -188,7 +193,7 @@
// Select item 1 programmatically
function(next) {
list.selectItem(1);
var item = document.elementFromPoint(list.clientWidth-50, 1 * list.height);
item = document.elementFromPoint(list.clientWidth-50, 1 * list.height);
waitFor(function() {
chai.assert(list.selection && list.selection == list.data[1],
'second item should be selected; selected id was ' + (list.selection && list.selection.id));
Expand Down
8 changes: 6 additions & 2 deletions tests/runner.html → test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
<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>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
runTests('tests.json');
WCT.loadSuites([
'core-list-basic.html',
'core-list-selection.html',
'core-list-data.html'
]);
</script>
</body>
</html>
5 changes: 0 additions & 5 deletions tests/js/htmltests.js

This file was deleted.

6 changes: 0 additions & 6 deletions tests/tests.json

This file was deleted.

0 comments on commit e1a0e5d

Please sign in to comment.