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

Side by Side Diff: node_modules/vulcanize/test/test.js

Issue 877193002: Upgrade vulcanize to 0.7.6. (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
« no previous file with comments | « node_modules/vulcanize/package.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * @license 2 * @license
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 4 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
6 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt 6 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
7 * Code distributed by Google as part of the polymer project is also 7 * Code distributed by Google as part of the polymer project is also
8 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt 8 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
9 */ 9 */
10 // jshint node: true 10 // jshint node: true
(...skipping 11 matching lines...) Expand all
22 var abs = constants.ABS_URL; 22 var abs = constants.ABS_URL;
23 23
24 assert(abs.test('data:charset=utf8,'), 'data urls'); 24 assert(abs.test('data:charset=utf8,'), 'data urls');
25 assert(abs.test('http://foo.com'), 'http'); 25 assert(abs.test('http://foo.com'), 'http');
26 assert(abs.test('https://foo.com'), 'https'); 26 assert(abs.test('https://foo.com'), 'https');
27 assert(abs.test('mailto:foo@bar.com'), 'mailto'); 27 assert(abs.test('mailto:foo@bar.com'), 'mailto');
28 assert(abs.test('tel:+49123123456'), 'phonecall'); 28 assert(abs.test('tel:+49123123456'), 'phonecall');
29 assert(abs.test('sms:1-123-123456'), 'sms'); 29 assert(abs.test('sms:1-123-123456'), 'sms');
30 assert(abs.test('//foo.com'), 'protocol-free'); 30 assert(abs.test('//foo.com'), 'protocol-free');
31 assert(abs.test('/components/'), '/'); 31 assert(abs.test('/components/'), '/');
32 assert(abs.test('#foo'), 'hash url');
32 assert(!abs.test('../foo/bar.html'), '../'); 33 assert(!abs.test('../foo/bar.html'), '../');
33 assert(!abs.test('bar.html'), 'sibling dependency'); 34 assert(!abs.test('bar.html'), 'sibling dependency');
34 }); 35 });
35 36
36 test('remote absolute urls', function() { 37 test('remote absolute urls', function() {
37 var rabs = constants.REMOTE_ABS_URL; 38 var rabs = constants.REMOTE_ABS_URL;
38 39
39 assert(rabs.test('http://foo.com'), 'http'); 40 assert(rabs.test('http://foo.com'), 'http');
40 assert(rabs.test('https://foo.com'), 'https'); 41 assert(rabs.test('https://foo.com'), 'https');
41 assert(rabs.test('//foo.com'), 'protocol-free'); 42 assert(rabs.test('//foo.com'), 'protocol-free');
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 }); 107 });
107 108
108 test('Rewrite Paths', function() { 109 test('Rewrite Paths', function() {
109 function testPath(val, expected, abs, msg) { 110 function testPath(val, expected, abs, msg) {
110 var actual = pathresolver.rewriteRelPath(inputPath, outputPath, val, abs); 111 var actual = pathresolver.rewriteRelPath(inputPath, outputPath, val, abs);
111 assert.equal(actual, expected, msg); 112 assert.equal(actual, expected, msg);
112 } 113 }
113 114
114 testPath('biz.jpg', 'my-element/biz.jpg', null, 'local'); 115 testPath('biz.jpg', 'my-element/biz.jpg', null, 'local');
115 testPath('http://foo/biz.jpg', 'http://foo/biz.jpg', null, 'remote'); 116 testPath('http://foo/biz.jpg', 'http://foo/biz.jpg', null, 'remote');
117 testPath('#foo', '#foo', null, 'hash');
116 testPath('biz.jpg', 'bar/my-element/biz.jpg', '/foo/', 'build path'); 118 testPath('biz.jpg', 'bar/my-element/biz.jpg', '/foo/', 'build path');
117 }); 119 });
118 120
119 test('Resolve Paths', function() { 121 test('Resolve Paths', function() {
120 var html = [ 122 var html = [
121 '<link rel="import" href="../polymer/polymer.html">', 123 '<link rel="import" href="../polymer/polymer.html">',
122 '<link rel="stylesheet" href="my-element.css">', 124 '<link rel="stylesheet" href="my-element.css">',
123 '<polymer-element name="my-element">', 125 '<polymer-element name="my-element">',
124 '<template>', 126 '<template>',
125 '<style>:host { background-image: url(background.svg); }</style>', 127 '<style>:host { background-image: url(background.svg); }</style>',
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 assert(vulcanized.indexOf('<style>polyfill-next-selector') > -1, 'polf ill-next-selector is kept'); 495 assert(vulcanized.indexOf('<style>polyfill-next-selector') > -1, 'polf ill-next-selector is kept');
494 done(); 496 done();
495 }); 497 });
496 }); 498 });
497 499
498 test('fallback on parse fail', function(done) { 500 test('fallback on parse fail', function(done) {
499 var input = '<style>div{\r\nwidth: {{ foo }};\n}\r\n</style>'; 501 var input = '<style>div{\r\nwidth: {{ foo }};\n}\r\n</style>';
500 process({inputSrc: input, output: outputPath, strip: true}, function(out puts) { 502 process({inputSrc: input, output: outputPath, strip: true}, function(out puts) {
501 var vulcanized = outputs[outputPath]; 503 var vulcanized = outputs[outputPath];
502 assert(vulcanized); 504 assert(vulcanized);
505 assert(vulcanized.indexOf('{{ foo }}') > -1, 'braces kept');
503 assert(vulcanized.indexOf(input.replace(/[\r\n]/g, '')) > -1, 'newline s removed at least'); 506 assert(vulcanized.indexOf(input.replace(/[\r\n]/g, '')) > -1, 'newline s removed at least');
504 done(); 507 done();
505 }); 508 });
506 }); 509 });
507 }); 510 });
508 511
509 test('comment removal', function(done) { 512 test('comment removal', function(done) {
510 var options = {input: 'test/html/comments.html', output: outputPath, strip : true}; 513 var options = {input: 'test/html/comments.html', output: outputPath, strip : true};
511 process(options, function(outputs) { 514 process(options, function(outputs) {
512 var vulcanized = outputs[outputPath]; 515 var vulcanized = outputs[outputPath];
513 assert(vulcanized); 516 assert(vulcanized);
514 assert.equal(vulcanized.indexOf('@license'), -1, 'license comment at top removed'); 517 assert.equal(vulcanized.indexOf('@license'), -1, 'license comment at top removed');
515 assert.equal(vulcanized.indexOf('comment 1'), -1, 'comment in body remov ed'); 518 assert.equal(vulcanized.indexOf('comment 1'), -1, 'comment in body remov ed');
516 assert.equal(vulcanized.indexOf('comment 2'), -1, 'comment in template r emoved'); 519 assert.equal(vulcanized.indexOf('comment 2'), -1, 'comment in template r emoved');
517 assert.equal(vulcanized.indexOf('comment 3'), -1, 'comment in style in t emplate removed'); 520 assert.equal(vulcanized.indexOf('comment 3'), -1, 'comment in style in t emplate removed');
518 assert.equal(vulcanized.indexOf('comment 4'), -1, 'comment in polymer-el ement removed'); 521 assert.equal(vulcanized.indexOf('comment 4'), -1, 'comment in polymer-el ement removed');
519 assert.equal(vulcanized.indexOf('comment 5'), -1, 'comment in script rem oved'); 522 assert.equal(vulcanized.indexOf('comment 5'), -1, 'comment in script rem oved');
520 done(); 523 done();
521 }); 524 });
522 }); 525 });
523 526
527 test('keep fallback declarations', function(done) {
528 var options = {inputSrc: '<style>div { display: flex; display: -webkit-fle x; }</style>', output: outputPath, strip: true};
529 process(options, function(outputs) {
530 var vulcanized = outputs[outputPath];
531 assert(vulcanized);
532 assert(vulcanized.indexOf('display: flex') > -1, 'keep flex');
533 assert(vulcanized.indexOf('display: -webkit-flex') > -1, 'keep -webkit-f lex');
534 done();
535 });
536 });
537
524 }); 538 });
525 539
526 test('Multiple Polymer Invocations', function(done) { 540 test('Multiple Polymer Invocations', function(done) {
527 var options = {input: 'test/html/multiple.html', output: outputPath}; 541 var options = {input: 'test/html/multiple.html', output: outputPath};
528 process(options, function(outputs) { 542 process(options, function(outputs) {
529 var vulcanized = outputs[outputPath]; 543 var vulcanized = outputs[outputPath];
530 assert(vulcanized); 544 assert(vulcanized);
531 var $ = require('whacko').load(vulcanized); 545 var $ = require('whacko').load(vulcanized);
532 var getText = require('../lib/utils.js').getTextContent; 546 var getText = require('../lib/utils.js').getTextContent;
533 var xa = $('polymer-element[name="x-a"] > script'); 547 var xa = $('polymer-element[name="x-a"] > script');
534 var xb = $('polymer-element[name="x-b"] > script'); 548 var xb = $('polymer-element[name="x-b"] > script');
535 assert.equal(getText(xa), 'Polymer(\'x-a\',{})'); 549 assert.equal(getText(xa), 'Polymer(\'x-a\',{})');
536 assert.equal(getText(xb), 'Polymer(\'x-b\',{})'); 550 assert.equal(getText(xb), 'Polymer(\'x-b\',{})');
537 done(); 551 done();
538 }); 552 });
539 }); 553 });
540 554
541 }); 555 });
OLDNEW
« no previous file with comments | « node_modules/vulcanize/package.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698