Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: polymer_0.5.0/bower_components/web-animations-js/test/js/dimension-handler.js

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 suite('dimension-handler', function() {
2 test('parse simple length values', function() {
3 assert.deepEqual(webAnimationsMinifill.parseLength(' 0 '), {px: 0});
4 assert.deepEqual(webAnimationsMinifill.parseLength('10px'), {px: 10});
5 assert.deepEqual(webAnimationsMinifill.parseLength('5VmIN'), {vmin: 5});
6 assert.deepEqual(webAnimationsMinifill.parseLength('-12.5em'), {em: -12.5});
7 });
8 test('parse length calcs', function() {
9 assert.deepEqual(webAnimationsMinifill.parseLength('calc(10px*3) '),
10 {px: 30});
11 assert.deepEqual(webAnimationsMinifill.parseLength('calc(10vmin + -5in) '),
12 {vmin: 10, 'in': -5});
13 assert.deepEqual(webAnimationsMinifill.parseLength('calc(5EM + 10px) '),
14 {em: 5, px: 10});
15 assert.deepEqual(webAnimationsMinifill.parseLength(' calc( 10px + 5em ) '),
16 {px: 10, em: 5});
17 assert.deepEqual(webAnimationsMinifill.parseLength('calc(5*(10px + 5em) - 5. 25em * 6)'),
18 {px: 50.0, em: -6.5});
19 assert.deepEqual(webAnimationsMinifill.parseLength('calc((5px + 2px)*(1 + 2* (4 + 2*-5)) + 7px - (5em + 6vw/2)*4)'),
20 {px: -70, em: -20, vw: -12});
21 assert.deepEqual(webAnimationsMinifill.parseLength('calc(calc(5px) + calc((( 3))) *calc(calc(10px)))'),
22 {px: 35});
23 });
24 test('invalid lengths fail to parse', function() {
25 assert.isUndefined(webAnimationsMinifill.parseLength('10'));
26 assert.isUndefined(webAnimationsMinifill.parseLength('()'));
27 assert.isUndefined(webAnimationsMinifill.parseLength('(10px)'));
28 assert.isUndefined(webAnimationsMinifill.parseLength('(10px + 5em)'));
29 assert.isUndefined(webAnimationsMinifill.parseLength('calc(10px + 5)'));
30 assert.isUndefined(webAnimationsMinifill.parseLength('calc(10px+ 5em)'));
31 assert.isUndefined(webAnimationsMinifill.parseLength('calc(10px +5em)'));
32 assert.isUndefined(webAnimationsMinifill.parseLength('calc(10px * 5em)'));
33 assert.isUndefined(webAnimationsMinifill.parseLength('(calc(10px + 5em))'));
34 assert.isUndefined(webAnimationsMinifill.parseLength('calc(10px + 5em))'));
35 assert.isUndefined(webAnimationsMinifill.parseLength('calc(10)'));
36 assert.isUndefined(webAnimationsMinifill.parseLength('calccalc(10px)'));
37 assert.isUndefined(webAnimationsMinifill.parseLength('calc(5 / 10px)'));
38 assert.isUndefined(webAnimationsMinifill.parseLength('calc(10px / 0)'));
39 assert.isUndefined(webAnimationsMinifill.parseLength('calc()'));
40 assert.isUndefined(webAnimationsMinifill.parseLength('ch'));
41 });
42 test('interpolate lengths and percents', function() {
43 assert.equal(webAnimationsMinifill.propertyInterpolation('left', '10px', '50 px')(0.25), '20px');
44 assert.equal(webAnimationsMinifill.propertyInterpolation('left', '10%', '50% ')(0.25), '20%');
45 assert.equal(webAnimationsMinifill.propertyInterpolation('left', '0px', '0.0 01px')(0.05), '0px');
46 assert.equal(webAnimationsMinifill.propertyInterpolation('left', '0px', '10p x')(0.234), '2.340px');
47 assert.equal(webAnimationsMinifill.propertyInterpolation('left', '10px', '10 em')(0.4), 'calc(6px + 4em)');
48 assert.equal(webAnimationsMinifill.propertyInterpolation('left', '10px', '10 %')(0.4), 'calc(6px + 4%)');
49 assert.equal(webAnimationsMinifill.propertyInterpolation('left', 'calc(10px + 5em)', 'calc(20px + 35em)')(0.4), 'calc(14px + 17em)');
50 assert.equal(webAnimationsMinifill.propertyInterpolation('left', 'calc(10px + 5em)', 'calc(20% + 35em)')(0.4), 'calc(6px + 17em + 8%)');
51 assert.equal(webAnimationsMinifill.propertyInterpolation('left', 'calc(10px + 5vw)', 'calc(20% + 35em)')(0.4), 'calc(6px + 3vw + 8% + 14em)');
52 });
53 test('consume simple length values', function() {
54 assert.isUndefined(webAnimationsMinifill.consumeLengthOrPercent('10px()'));
55 assert.deepEqual(webAnimationsMinifill.consumeLengthOrPercent('10px,'),
56 [{px: 10}, ',']);
57 assert.deepEqual(webAnimationsMinifill.consumeLengthOrPercent('10px,20px'),
58 [{px: 10}, ',20px']);
59 assert.deepEqual(webAnimationsMinifill.consumeLengthOrPercent('0 blah'),
60 [{px: 0}, ' blah']);
61 });
62 test('consume length calcs', function() {
63 assert.deepEqual(webAnimationsMinifill.consumeLengthOrPercent('calc(10px)()' ),
64 [{px: 10}, '()']);
65 assert.deepEqual(webAnimationsMinifill.consumeLengthOrPercent('calc((5px + 2 px)*(1 + 2*(4 + 2*-5)) + 7px - (5em + 6vw/2)*4)blah'),
66 [{px: -70, em: -20, vw: -12}, 'blah']);
67 });
68 test('consume fails on invalid input', function() {
69 assert.isUndefined(webAnimationsMinifill.consumeLengthOrPercent('()'));
70 assert.isUndefined(webAnimationsMinifill.consumeLengthOrPercent('(10px'));
71 assert.isUndefined(webAnimationsMinifill.consumeLengthOrPercent('(10px)'));
72 assert.isUndefined(webAnimationsMinifill.consumeLengthOrPercent('calc(10px,1 0px)'));
73 });
74 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698