18f76a6190
This change runs all tests with Shadow DOM both on and off (in supported browsers). It also fixes issues that needed to be addressed due to a lack of understanding about Shadow DOM in light of it not being turned on. For more info on where 99% of the issues were, visit https://www.polymer-project.org/1.0/docs/devguide/local-dom.html This also removes a test-fixture dep and moves to webcomponents-lite.js per https://github.com/PolymerElements/polymer-starter-kit/issues/473 Change-Id: I93889d99442af5ecfc0165f45373c8a24fb74e0d
82 lines
2.5 KiB
HTML
82 lines
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
Copyright (C) 2015 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
|
<title>gr-date-formatter</title>
|
|
|
|
<script src="../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
|
|
<script src="../../bower_components/web-component-tester/browser.js"></script>
|
|
<script src="../scripts/util.js"></script>
|
|
|
|
<link rel="import" href="../elements/gr-date-formatter.html">
|
|
|
|
<test-fixture id="basic">
|
|
<template>
|
|
<gr-date-formatter date-str="2015-09-24 23:30:17.033000000"></gr-date-formatter>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
suite('gr-date-formatter tests', function() {
|
|
var element;
|
|
|
|
setup(function() {
|
|
element = fixture('basic');
|
|
});
|
|
|
|
test('date is parsed correctly', function() {
|
|
assert.notOk((new Date('foo')).valueOf());
|
|
var d = element._parseDateStr(element.getAttribute('date-str'));
|
|
assert.isAbove(d.valueOf(), 0);
|
|
});
|
|
|
|
function normalizedDate(dateStr) {
|
|
var d = new Date(dateStr);
|
|
d.setMinutes(d.getMinutes() + d.getTimezoneOffset());
|
|
return d;
|
|
}
|
|
|
|
function testDates(nowStr, dateStr, expected) {
|
|
var now = normalizedDate(nowStr);
|
|
var t = normalizedDate(dateStr);
|
|
assert.equal(element._dateStr(t, now), expected);
|
|
}
|
|
|
|
test('dates strings are correct', function() {
|
|
// Within 24 hours on same day.
|
|
testDates('2015-07-29T20:34:00.000Z',
|
|
'2015-07-29T15:34:00.000Z',
|
|
'3:34 PM');
|
|
|
|
// Within 24 hours on different days.
|
|
testDates('2015-07-29T03:34:00.000Z',
|
|
'2015-07-28T20:25:00.000Z',
|
|
'Jul 28');
|
|
|
|
// More than 24 hours. Less than six months.
|
|
testDates('2015-07-29T20:34:00.000Z',
|
|
'2015-06-15T03:25:00.000Z',
|
|
'Jun 15');
|
|
|
|
// More than six months.
|
|
testDates('2015-09-15T20:34:00.000Z',
|
|
'2015-01-15T03:25:00.000Z',
|
|
'Jan 15, 2015');
|
|
});
|
|
});
|
|
</script>
|