npm install web-component-tester --save-dev
wct.conf.js
module.exports = {
verbose: true,
plugins: {
local: {
browsers: ['chrome']
}
}
};
node node_modules/web-component-tester/bin/wct
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1">
<script src="../bower_components/webcomponentsjs/webcomponents.min.js"></script>
<script src="../node_modules/web-component-tester/browser.js"></script>
<link rel="import" href="../src/utils.html">
</head>
<body>
<my-utils id="utils"></my-utils>
<script>
test('utils.isNumeric', function(){
var utils = document.getElementById('utils');
[1,0,-1,1.83,-9.87].forEach(function(d){
assert.isTrue(utils.isNumeric(d));
});
[true, false, null, {}, 'a', new Date()].forEach(function(d){
assert.isFalse(utils.isNumeric(d));
});
});
</script>
</body>
</html>
<link rel="import" href="../bower_components/polymer/polymer.html">
<dom-module id="my-utils">
<template></template>
</dom-module>
Polymer({
is: "my-utils",
isNumeric: function(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
});