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

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

Issue 895523005: Added Polymer 0.5.4 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 10 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(webAnimations1.parseLength(' 0 '), {px: 0});
4 assert.deepEqual(webAnimations1.parseLength('10px'), {px: 10});
5 assert.deepEqual(webAnimations1.parseLength('5VmIN'), {vmin: 5});
6 assert.deepEqual(webAnimations1.parseLength('-12.5em'), {em: -12.5});
7 });
8 test('parse length calcs', function() {
9 assert.deepEqual(webAnimations1.parseLength('calc(10px*3) '),
10 {px: 30});
11 assert.deepEqual(webAnimations1.parseLength('calc(10vmin + -5in) '),
12 {vmin: 10, 'in': -5});
13 assert.deepEqual(webAnimations1.parseLength('calc(5EM + 10px) '),
14 {em: 5, px: 10});
15 assert.deepEqual(webAnimations1.parseLength(' calc( 10px + 5em ) '),
16 {px: 10, em: 5});
17 assert.deepEqual(webAnimations1.parseLength('calc(5*(10px + 5em) - 5.25em * 6)'),
18 {px: 50.0, em: -6.5});
19 assert.deepEqual(webAnimations1.parseLength('calc((5px + 2px)*(1 + 2*(4 + 2* -5)) + 7px - (5em + 6vw/2)*4)'),
20 {px: -70, em: -20, vw: -12});
21 assert.deepEqual(webAnimations1.parseLength('calc(calc(5px) + calc(((3))) *c alc(calc(10px)))'),
22 {px: 35});
23 });
24 test('invalid lengths fail to parse', function() {
25 assert.isUndefined(webAnimations1.parseLength('10'));
26 assert.isUndefined(webAnimations1.parseLength('()'));
27 assert.isUndefined(webAnimations1.parseLength('(10px)'));
28 assert.isUndefined(webAnimations1.parseLength('(10px + 5em)'));
29 assert.isUndefined(webAnimations1.parseLength('calc(10px + 5)'));
30 assert.isUndefined(webAnimations1.parseLength('calc(10px+ 5em)'));
31 assert.isUndefined(webAnimations1.parseLength('calc(10px +5em)'));
32 assert.isUndefined(webAnimations1.parseLength('calc(10px * 5em)'));
33 assert.isUndefined(webAnimations1.parseLength('(calc(10px + 5em))'));
34 assert.isUndefined(webAnimations1.parseLength('calc(10px + 5em))'));
35 assert.isUndefined(webAnimations1.parseLength('calc(10)'));
36 assert.isUndefined(webAnimations1.parseLength('calccalc(10px)'));
37 assert.isUndefined(webAnimations1.parseLength('calc(5 / 10px)'));
38 assert.isUndefined(webAnimations1.parseLength('calc(10px / 0)'));
39 assert.isUndefined(webAnimations1.parseLength('calc()'));
40 assert.isUndefined(webAnimations1.parseLength('ch'));
41 });
42 test('interpolate lengths and percents', function() {
43 assert.equal(webAnimations1.propertyInterpolation('left', '10px', '50px')(0. 25), '20px');
44 assert.equal(webAnimations1.propertyInterpolation('left', '10%', '50%')(0.25 ), '20%');
45 assert.equal(webAnimations1.propertyInterpolation('left', '0px', '0.001px')( 0.05), '0px');
46 assert.equal(webAnimations1.propertyInterpolation('left', '0px', '10px')(0.2 34), '2.340px');
47 assert.equal(webAnimations1.propertyInterpolation('left', '10px', '10em')(0. 4), 'calc(6px + 4em)');
48 assert.equal(webAnimations1.propertyInterpolation('left', '10px', '10%')(0.4 ), 'calc(6px + 4%)');
49 assert.equal(webAnimations1.propertyInterpolation('left', 'calc(10px + 5em)' , 'calc(20px + 35em)')(0.4), 'calc(14px + 17em)');
50 assert.equal(webAnimations1.propertyInterpolation('left', 'calc(10px + 5em)' , 'calc(20% + 35em)')(0.4), 'calc(6px + 17em + 8%)');
51 assert.equal(webAnimations1.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(webAnimations1.consumeLengthOrPercent('10px()'));
55 assert.deepEqual(webAnimations1.consumeLengthOrPercent('10px,'),
56 [{px: 10}, ',']);
57 assert.deepEqual(webAnimations1.consumeLengthOrPercent('10px,20px'),
58 [{px: 10}, ',20px']);
59 assert.deepEqual(webAnimations1.consumeLengthOrPercent('0 blah'),
60 [{px: 0}, ' blah']);
61 });
62 test('consume length calcs', function() {
63 assert.deepEqual(webAnimations1.consumeLengthOrPercent('calc(10px)()'),
64 [{px: 10}, '()']);
65 assert.deepEqual(webAnimations1.consumeLengthOrPercent('calc((5px + 2px)*(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(webAnimations1.consumeLengthOrPercent('()'));
70 assert.isUndefined(webAnimations1.consumeLengthOrPercent('(10px'));
71 assert.isUndefined(webAnimations1.consumeLengthOrPercent('(10px)'));
72 assert.isUndefined(webAnimations1.consumeLengthOrPercent('calc(10px,10px)')) ;
73 });
74 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698