Permalink
Browse files

feat(test): add missing tests

  • Loading branch information...
sparanoid committed Aug 12, 2015
1 parent d296437 commit 8d4fb88189fc7b92b3ade5276543593c083af3ae
@@ -35,6 +35,78 @@ module.exports = function(grunt) {
'tmp/default_options': 'test/fixtures/index.html',
},
},
minify: {
options: {
minify: false,
inlineImg: false,
inlineSvg: false,
inlineSvgBase64: false
},
files: {
'tmp/minify': 'test/fixtures/index.html',
},
},
inline_img: {
options: {
minify: false,
inlineImg: true,
inlineSvg: false,
inlineSvgBase64: false
},
files: {
'tmp/inline_img': 'test/fixtures/index.html',
},
},
inline_svg: {
options: {
minify: false,
inlineImg: false,
inlineSvg: true,
inlineSvgBase64: false
},
files: {
'tmp/inline_svg': 'test/fixtures/index.html',
},
},
inline_svg_base64: {
options: {
minify: false,
inlineImg: false,
inlineSvg: true,
inlineSvgBase64: true
},
files: {
'tmp/inline_svg_base64': 'test/fixtures/index.html',
},
},
include_tag: {
options: {
minify: false,
inlineImg: false,
inlineSvg: false,
inlineSvgBase64: false,
includeTag: "?assets-inline"
},
files: {
'tmp/include_tag': 'test/fixtures/index.html',
},
},
all: {
options: {
jsDir: "",
cssDir: "",
assetsDir: "",
minify: true,
inlineImg: true,
inlineSvg: true,
inlineSvgBase64: true,
includeTag: "",
assetsUrlPrefix: "/lab/test/"
},
files: {
'tmp/all': 'test/fixtures/index.html',
},
}
},
// Unit tests.
@@ -36,4 +36,58 @@ exports.assets_inline = {
test.done();
},
minify: function(test){
test.expect(1);
var actual = grunt.file.read('tmp/minify');
var expected = grunt.file.read('test/expected/minify');
test.equal(actual, expected, 'tests minified css');
test.done();
},
inline_img: function(test){
test.expect(1);
var actual = grunt.file.read('tmp/inline_img');
var expected = grunt.file.read('test/expected/inline_img');
test.equal(actual, expected, 'tests inline css images');
test.done();
},
inline_svg: function(test){
test.expect(1);
var actual = grunt.file.read('tmp/inline_svg');
var expected = grunt.file.read('test/expected/inline_svg');
test.equal(actual, expected, 'tests inline images');
test.done();
},
inline_svg_base64: function(test){
test.expect(1);
var actual = grunt.file.read('tmp/inline_svg_base64');
var expected = grunt.file.read('test/expected/inline_svg_base64');
test.equal(actual, expected, 'tests inline images');
test.done();
},
include_tag: function(test){
test.expect(1);
var actual = grunt.file.read('tmp/include_tag');
var expected = grunt.file.read('test/expected/include_tag');
test.equal(actual, expected, 'tests inline images');
test.done();
},
all: function(test){
test.expect(1);
var actual = grunt.file.read('tmp/all');
var expected = grunt.file.read('test/expected/all');
test.equal(actual, expected, 'tests inline images');
test.done();
}
};

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css">
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css?assets-inline">
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css?assets-inline">
<style>@font-face {
font-family: 'FontAwesome';
src: url('fonts/fontawesome-webfont.eot?v=4.0.3');
@@ -14,15 +14,58 @@
h1 {
color: red;
}
.backgroud-test-image {
width: 1000px;
height: 200px;
background: url("img/imouto-logo-large.png");
}
.backgroud-test-svg {
width: 1000px;
height: 200px;
background: url("svg/disable-wysiwyg.svg");
}
</style>
<style>/* Only this file should be smooshed if `includeTag` is defined. */
body {
background: gray;
}
</style>
</head>
<body>
<h1>grunt-assets-inline</h1>
<p>Hello world! This is a test.</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<h2>This is a background image</h2>
<div class="backgroud-test-image"></div>
<h2>This is a SVG background</h2>
<div class="backgroud-test-svg"></div>
<h2>This is an image</h2>
<img src="img/imouto-logo-large.png">
<h2>This is a SVG image</h2>
<img src="data:image/svg+xml;utf8,&lt;svg xmlns=&apos;http://www.w3.org/2000/svg&apos; viewBox=&apos;0 0 2366 285&apos; enable-background=&apos;new 0 0 2366 285&apos;&gt;&lt;title&gt;Disable WYSIWYG&lt;/title&gt;&lt;g fill=&apos;#CB3920&apos;&gt;&lt;path d=&apos;M.5 262.5h285V285H.5zM128 105H.5v127.5H128V105zm-22.5 105H23v-82.5h82.5V210zm52.5 0h127.5v22.5H158zM.5 0h285v22.5H.5zm0 52.5h285V75H.5zM158 105h127.5v22.5H158zm0 52.5h127.5V180H158zM409 247.1h38.3c59.6 0 106.8-31.1 106.8-95.5 0-62.9-48.1-93.5-106-93.5H409v189zm23.6-167.4h8.3c48.1 0 89.7 17.8 89.7 72.9 0 54.9-41.6 72.9-89.7 72.9h-8.3V79.7zm141.3 167.4h22.6V129.8h-22.6v117.3zm11.3-186.7c-8.5 0-15.5 7-15.5 15.8 0 8.5 7 15.3 15.5 15.3s15.5-6.8 15.5-15.3c.1-8.8-7-15.8-15.5-15.8zm103.1 86.4c-6.3-12.8-17.8-20.5-32.1-20.5-19 0-34.6 15-34.6 34.1 0 16 9.5 22.6 22.6 29.6l22.1 11.8c5.3 3.5 8.3 6.5 8.3 12.8 0 10-8.3 16.5-17.8 16.5-10.8 0-16.5-6.3-21.3-15l-19.3 8.8c6.3 16.5 23.6 26.3 40.6 26.3 21.8 0 40.3-16.5 40.3-38.8 0-18.5-13.3-27.1-27.1-33.3-13.8-6.3-27.3-10.8-27.3-21.1 0-6.5 6-11.5 12.3-11.5 6.5 0 12.3 4.5 15 10.3l18.3-10m77.9 84.2c-23.8 0-37.1-20.6-37.1-42.6 0-21.8 13.8-42.1 37.1-42.1 24.3 0 38.1 19.3 38.1 42.1-.1 23.1-13.6 42.6-38.1 42.6zm59.3-101.2H803v19.5h-.5c-9.3-14-23.3-23.1-40.6-23.1-34.1 0-55.4 29.3-55.4 61.4 0 33.6 20.3 63.4 56.1 63.4 16.8 0 30.8-9 39.8-22.3h.5V247h22.6V129.8zM908.2 231c-23.8 0-37.1-20.6-37.1-42.6 0-21.8 13.8-42.1 37.1-42.1 24.3 0 38.1 19.3 38.1 42.1 0 23.1-13.5 42.6-38.1 42.6zm-58.4 16.1h22.6v-18.3h.5c9 13.3 23.3 22.3 39.8 22.3 36.1 0 56.1-29.8 56.1-63.4 0-32.1-21.3-61.4-55.1-61.4-17.5 0-31.6 9-40.8 23.1h-.5V29.5h-22.6v217.6zM988.2 29.5h22.6V247h-22.6V29.5zM1142 192.2v-3.5c0-34.8-17.5-62.4-54.9-62.4-37.8 0-57.1 27.1-57.1 63.2 0 34.6 21.8 61.6 57.6 61.6 22.8 0 43.4-11.8 54.4-32.1l-19-10.8c-8.5 14-17.8 22.8-35.1 22.8-21.6 0-35.1-18.8-35.3-38.8h89.4zm907.2-130.9L1972 254.6 1918.6 116l-53.4 138.6-78.4-196.5h25.6l52.9 135.3 53.4-139.3 53.4 139.3L2025 58.1h49.5l46.4 80.7 46.4-80.7h27.1l-61.6 106.8v82.2H2109v-82.2l-59.8-103.6zm-571.7 0l-77.2 193.3L1347 116l-53.4 138.6-78.4-196.5h25.6l52.9 135.3L1347 54.1l53.4 139.3 52.9-135.3h49.5l46.4 80.7 46.4-80.7h27.1l-61.6 106.8v82.2h-23.6v-82.2l-60-103.6zm-423.7 113.8c2.8-16.8 15.8-29.3 33.3-29.3 18 0 29.6 11.8 32.3 29.3h-65.6zm675.7-92.4c-10.3-18.3-27.6-28.6-48.6-28.6-28.6 0-55.6 18.3-55.6 48.9 0 26.3 19.5 38.6 41.1 47.9l13 5.5c16.3 6.8 32.6 15.5 32.6 35.8 0 19.8-14.5 36.8-34.8 36.8-20.3 0-36.8-15-36.6-35.8l-23.8 5c4 30.3 27.8 52.9 58.4 52.9 33.8 0 60.4-24.6 60.4-58.9 0-31.6-20-46.4-46.9-56.9l-13.5-5.3c-11.8-4.5-26.3-12.3-26.3-27.1 0-16.5 16.5-26.8 31.6-26.8 14.3 0 23.3 6 30.3 17.8l18.7-11.2zm25.5-24.6h23.6v189H1755v-189zm535.7 93.7v21.6h48.9c-1 30.8-32.6 56.1-61.9 56.1-40.8 0-73.4-37.6-73.4-77.2 0-42.4 33.1-76.7 75.4-76.7 23.1 0 45.9 12.3 59.4 30.8l16.5-15.8C2337.1 67.3 2308 54 2278.7 54c-54.4 0-98 44.6-98 99 0 52.4 42.6 98 95.5 98s89.5-39.8 89.5-91.7v-7.5h-75z&apos;/&gt;&lt;/g&gt;&lt;/svg&gt;">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js?assets-inline"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js?assets-inline"></script>
<script>alert('This should not be replaced.');</script>
<script>alert('lol i am test js, really');
<script>var appFunc = function(i) {
return i;
console.log("This is an uncompressed JS code")
};
alert('lol i am test script, really');
</script>
<script>var inlineFunc = function(i) {
return i;
console.log("This is an uncompressed JS code")
};
console.log("Only this file should be smooshed if `includeTag` is defined.");
</script>
</body>
</html>
@@ -0,0 +1,45 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css?assets-inline">
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css?assets-inline">
<link rel="stylesheet" href="css/app.css">
<style>/* Only this file should be smooshed if `includeTag` is defined. */
body {
background: gray;
}
</style>
</head>
<body>
<h1>grunt-assets-inline</h1>
<p>Hello world! This is a test.</p>
<h2>This is a background image</h2>
<div class="backgroud-test-image"></div>
<h2>This is a SVG background</h2>
<div class="backgroud-test-svg"></div>
<h2>This is an image</h2>
<img src="img/imouto-logo-large.png">
<h2>This is a SVG image</h2>
<img src="svg/disable-wysiwyg.svg">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js?assets-inline"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js?assets-inline"></script>
<script>alert('This should not be replaced.');</script>
<script src="js/app.js"></script>
<script>var inlineFunc = function(i) {
return i;
console.log("This is an uncompressed JS code")
};
console.log("Only this file should be smooshed if `includeTag` is defined.");
</script>
</body>
</html>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,71 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css?assets-inline">
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css?assets-inline">
<style>@font-face {
font-family: 'FontAwesome';
src: url('fonts/fontawesome-webfont.eot?v=4.0.3');
}
h1 {
color: red;
}
.backgroud-test-image {
width: 1000px;
height: 200px;
background: url("img/imouto-logo-large.png");
}
.backgroud-test-svg {
width: 1000px;
height: 200px;
background: url("svg/disable-wysiwyg.svg");
}
</style>
<style>/* Only this file should be smooshed if `includeTag` is defined. */
body {
background: gray;
}
</style>
</head>
<body>
<h1>grunt-assets-inline</h1>
<p>Hello world! This is a test.</p>
<h2>This is a background image</h2>
<div class="backgroud-test-image"></div>
<h2>This is a SVG background</h2>
<div class="backgroud-test-svg"></div>
<h2>This is an image</h2>
<img src="img/imouto-logo-large.png">
<h2>This is a SVG image</h2>
<img src="data:image/svg+xml;utf8,&lt;svg xmlns=&apos;http://www.w3.org/2000/svg&apos; viewBox=&apos;0 0 2366 285&apos; enable-background=&apos;new 0 0 2366 285&apos;&gt;&lt;title&gt;Disable WYSIWYG&lt;/title&gt;&lt;g fill=&apos;#CB3920&apos;&gt;&lt;path d=&apos;M.5 262.5h285V285H.5zM128 105H.5v127.5H128V105zm-22.5 105H23v-82.5h82.5V210zm52.5 0h127.5v22.5H158zM.5 0h285v22.5H.5zm0 52.5h285V75H.5zM158 105h127.5v22.5H158zm0 52.5h127.5V180H158zM409 247.1h38.3c59.6 0 106.8-31.1 106.8-95.5 0-62.9-48.1-93.5-106-93.5H409v189zm23.6-167.4h8.3c48.1 0 89.7 17.8 89.7 72.9 0 54.9-41.6 72.9-89.7 72.9h-8.3V79.7zm141.3 167.4h22.6V129.8h-22.6v117.3zm11.3-186.7c-8.5 0-15.5 7-15.5 15.8 0 8.5 7 15.3 15.5 15.3s15.5-6.8 15.5-15.3c.1-8.8-7-15.8-15.5-15.8zm103.1 86.4c-6.3-12.8-17.8-20.5-32.1-20.5-19 0-34.6 15-34.6 34.1 0 16 9.5 22.6 22.6 29.6l22.1 11.8c5.3 3.5 8.3 6.5 8.3 12.8 0 10-8.3 16.5-17.8 16.5-10.8 0-16.5-6.3-21.3-15l-19.3 8.8c6.3 16.5 23.6 26.3 40.6 26.3 21.8 0 40.3-16.5 40.3-38.8 0-18.5-13.3-27.1-27.1-33.3-13.8-6.3-27.3-10.8-27.3-21.1 0-6.5 6-11.5 12.3-11.5 6.5 0 12.3 4.5 15 10.3l18.3-10m77.9 84.2c-23.8 0-37.1-20.6-37.1-42.6 0-21.8 13.8-42.1 37.1-42.1 24.3 0 38.1 19.3 38.1 42.1-.1 23.1-13.6 42.6-38.1 42.6zm59.3-101.2H803v19.5h-.5c-9.3-14-23.3-23.1-40.6-23.1-34.1 0-55.4 29.3-55.4 61.4 0 33.6 20.3 63.4 56.1 63.4 16.8 0 30.8-9 39.8-22.3h.5V247h22.6V129.8zM908.2 231c-23.8 0-37.1-20.6-37.1-42.6 0-21.8 13.8-42.1 37.1-42.1 24.3 0 38.1 19.3 38.1 42.1 0 23.1-13.5 42.6-38.1 42.6zm-58.4 16.1h22.6v-18.3h.5c9 13.3 23.3 22.3 39.8 22.3 36.1 0 56.1-29.8 56.1-63.4 0-32.1-21.3-61.4-55.1-61.4-17.5 0-31.6 9-40.8 23.1h-.5V29.5h-22.6v217.6zM988.2 29.5h22.6V247h-22.6V29.5zM1142 192.2v-3.5c0-34.8-17.5-62.4-54.9-62.4-37.8 0-57.1 27.1-57.1 63.2 0 34.6 21.8 61.6 57.6 61.6 22.8 0 43.4-11.8 54.4-32.1l-19-10.8c-8.5 14-17.8 22.8-35.1 22.8-21.6 0-35.1-18.8-35.3-38.8h89.4zm907.2-130.9L1972 254.6 1918.6 116l-53.4 138.6-78.4-196.5h25.6l52.9 135.3 53.4-139.3 53.4 139.3L2025 58.1h49.5l46.4 80.7 46.4-80.7h27.1l-61.6 106.8v82.2H2109v-82.2l-59.8-103.6zm-571.7 0l-77.2 193.3L1347 116l-53.4 138.6-78.4-196.5h25.6l52.9 135.3L1347 54.1l53.4 139.3 52.9-135.3h49.5l46.4 80.7 46.4-80.7h27.1l-61.6 106.8v82.2h-23.6v-82.2l-60-103.6zm-423.7 113.8c2.8-16.8 15.8-29.3 33.3-29.3 18 0 29.6 11.8 32.3 29.3h-65.6zm675.7-92.4c-10.3-18.3-27.6-28.6-48.6-28.6-28.6 0-55.6 18.3-55.6 48.9 0 26.3 19.5 38.6 41.1 47.9l13 5.5c16.3 6.8 32.6 15.5 32.6 35.8 0 19.8-14.5 36.8-34.8 36.8-20.3 0-36.8-15-36.6-35.8l-23.8 5c4 30.3 27.8 52.9 58.4 52.9 33.8 0 60.4-24.6 60.4-58.9 0-31.6-20-46.4-46.9-56.9l-13.5-5.3c-11.8-4.5-26.3-12.3-26.3-27.1 0-16.5 16.5-26.8 31.6-26.8 14.3 0 23.3 6 30.3 17.8l18.7-11.2zm25.5-24.6h23.6v189H1755v-189zm535.7 93.7v21.6h48.9c-1 30.8-32.6 56.1-61.9 56.1-40.8 0-73.4-37.6-73.4-77.2 0-42.4 33.1-76.7 75.4-76.7 23.1 0 45.9 12.3 59.4 30.8l16.5-15.8C2337.1 67.3 2308 54 2278.7 54c-54.4 0-98 44.6-98 99 0 52.4 42.6 98 95.5 98s89.5-39.8 89.5-91.7v-7.5h-75z&apos;/&gt;&lt;/g&gt;&lt;/svg&gt;">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js?assets-inline"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js?assets-inline"></script>
<script>alert('This should not be replaced.');</script>
<script>var appFunc = function(i) {
return i;
console.log("This is an uncompressed JS code")
};
alert('lol i am test script, really');
</script>
<script>var inlineFunc = function(i) {
return i;
console.log("This is an uncompressed JS code")
};
console.log("Only this file should be smooshed if `includeTag` is defined.");
</script>
</body>
</html>
Oops, something went wrong.

0 comments on commit 8d4fb88

Please sign in to comment.