Permalink
Browse files

add some test case

add some test case
  • Loading branch information...
1 parent 6ba6abf commit 10f1642eda0dc5e9043493742b343b4c4188e60f @miniflycn miniflycn committed Sep 13, 2013
View
@@ -0,0 +1,16 @@
+############
+## Windows
+############
+
+# Windows image file caches
+Thumbs.db
+
+# Folder config file
+Desktop.ini
+
+#############
+## My Project
+#############
+
+node_modules/
+tmp/
View
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+ - "0.10"
+ - "0.8"
+before_script:
+ - npm install -g grunt-cli
View
@@ -0,0 +1,45 @@
+'use strict';
+
+module.exports = function(grunt) {
+ grunt.initConfig({
+ inline: {
+ dist: {
+ src: ['test/dist/css.html', 'test/dist/img.html', 'test/dist/html.html'],
+ dest: ['tmp/']
+ }
+ },
+
+ clean: {
+ tests: ['tmp/']
+ },
+
+ htmlmin: {
+ dist: {
+ options: {
+ removeComments: true,
+ collapseWhitespace: true
+ },
+ files: {
+ 'tmp/css.min.html': 'tmp/css.html',
+ 'tmp/img.min.html': 'tmp/img.html',
+ 'tmp/html.min.html': 'tmp/html.html'
+ }
+ }
+ },
+
+ // Unit tests
+ nodeunit: {
+ tests: ['test/*_test.js']
+ }
+ });
+
+ grunt.loadTasks('tasks');
+
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-htmlmin');
+ grunt.loadNpmTasks('grunt-contrib-nodeunit');
+
+ grunt.registerTask('test', ['clean', 'inline', 'htmlmin', 'nodeunit']);
+ // By default, run all tests
+ grunt.registerTask('default', ['test']);
+};
View
@@ -1,32 +1,38 @@
-{
- "author": {
- "name": "程序猿小卡",
- "email": "chyingp@gmail.com",
- "url": "https://github.com/chyingp"
- },
- "name": "grunt-inline",
- "description": "将标记为inline的<script>、<link>、<img>等资源进行内嵌",
- "version": "0.1.9",
- "keywords": [
- "gruntplugin",
- "inline",
- "js",
- "css"
- ],
- "main": "inline",
- "repository": {
- "type": "git",
- "url": "https://github.com/chyingp/grunt-inline.git"
- },
- "engines": {
- "node": ">=0.8.0"
- },
- "devDependencies": {
- "datauri": "~0.2.0"
- },
- "dependencies": {
- "datauri": "~0.2.0"
- },
- "_id": "grunt-inline@0.1.0",
- "_from": "grunt-inline@~0.1.0"
-}
+{
+ "author": {
+ "name": "程序猿小卡",
+ "email": "chyingp@gmail.com",
+ "url": "https://github.com/chyingp"
+ },
+ "name": "grunt-inline",
+ "description": "将标记为inline的<script>、<link>、<img>等资源进行内嵌",
+ "version": "0.1.9",
+ "keywords": [
+ "gruntplugin",
+ "inline",
+ "js",
+ "css"
+ ],
+ "main": "inline",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/chyingp/grunt-inline.git"
+ },
+ "engines": {
+ "node": ">=0.8.0"
+ },
+ "devDependencies": {
+ "grunt-contrib-nodeunit": "~0.1.2",
+ "grunt-contrib-clean": "~0.4.0",
+ "grunt-contrib-htmlmin": "~0.1.3",
+ "grunt": "~0.4.0"
+ },
+ "dependencies": {
+ "datauri": "~0.2.0"
+ },
+ "scripts": {
+ "test": "grunt test"
+ },
+ "_id": "grunt-inline@0.1.0",
+ "_from": "grunt-inline@~0.1.0"
+}
View
@@ -1,21 +0,0 @@
-module.exports = function(grunt) {
-
- // Project configuration.
- grunt.initConfig({
-
- inline: {
- dist: {
- src: ['dist/index.html'],
- dest: ['dev/']
- }
- }
-
- });
-
- // Load the plugin that provides the "uglify" task.
- grunt.loadNpmTasks('grunt-inline');
-
- // Default task(s).
- grunt.registerTask('default', ['inline']);
-
-};
@@ -5,13 +5,9 @@
<!-- ended with "/>" -->
<link href="styles/main.css?__inline=true" rel="stylesheet" />
-
<!-- ended with ">" -->
- <link href="styles/main.css?__inline=true" rel="stylesheet" /></head>
-
- <!-- inline tag -->
- <inline src="test.html" />
+ <link href="styles/main.css?__inline=true" rel="stylesheet">
+</head>
<body>
-
</body>
</html>
View
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>test</title>
+</head>
+<body>
+<!-- inline html -->
+<inline src="html/test.html" />
+</body>
+</html>
View
@@ -0,0 +1 @@
+<p>test</p>
View
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>test</title>
+</head>
+<body>
+ <!-- inline image -->
+ <img src="img/icon.png?__inline=true" />
+</body>
+</html>
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1 @@
+<!DOCTYPE html><html><head><title>test</title><style>.main{border: none;}</style><style>.main{border: none;}</style></head><body></body></html>
@@ -0,0 +1 @@
+<!DOCTYPE html><html><head><title>test</title></head><body><p>test</p></body></html>
@@ -0,0 +1 @@
+<!DOCTYPE html><html><head><title>test</title></head><body><img src="data:image/png;base64data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAwCAYAAADgvwGgAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABUlJREFUeNq8WFtsVEUY/ufsWbbtsl1aWtqCBKlJtVakTSEGa4IvJqiJPmg0PmjwRZONBGJDAzHYmD54i40PatCoMeEBL28N6oORROSlloqWW420hRbtZVvYXpa17Z4zfjNndnt2zzl7iJad5Ns5Z87MfPNf5p9/ljHGAkRkkFthjIhz1NkGq5Jt6putmKZJhYpOnmScVrtomDRoTWwDX30iSzIOFKlAMgoUk0wrJhmXTsbYbSeDvVgKNKVwiRq8rwfKlGpTwDgwumps2Gc9TGNDqJOouQTL1nNAL573ARGmaSQBLWRrGzi8uBCYmFiqsZC3Wxo+D7yCl1MYuREja+QMRBNKA76bmihvk2Ulc4eQvh91Qklvor4hpWdsn69k2++u56HQGhqfmqGxiXhGtXSL0lp9rOdB0zAbCzpI37Fu0vUAJZI36WTfAHV+eIwuDI1iPMudmOeROCPbSV/XDzCTzPQyVZSV0FOPPUynvniX9rS1KnN4hEnuIiWjHl9n5MO9wk3IXEiQmZwjPVxG8ekb1PrcAanWrEodJDl6HgB2YIHLBSWbnFyiifFFStdtJ72+hdKpRareuIGeea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8ADdbt5b+TYZuxu0AZxdsWCFoh3RVjoaAFTDOEbiIBTfjYSxJCjX5aZFEVThyWFMcIz5/5f5CJEzJY3Dt1EcnMYpEhEDPDGRhu0z88ftec1VZjuvB1e3XJjOJQEf0rwABVXGHq9lRcdAAAAABJRU5ErkJggg=="></body></html>
View
@@ -0,0 +1,43 @@
+var grunt = require('grunt');
+var fs = require('fs');
+
+function readFile(file) {
+ 'use strict';
+
+ var contents = grunt.file.read(file);
+
+ if (process.platform === 'win32') {
+ contents = contents.replace(/\r\n/g, '\n');
+ }
+
+ return contents;
+}
+
+function assertFileEquality(test, pathToActual, pathToExpected, message) {
+ var actual = readFile(pathToActual);
+ var expected = readFile(pathToExpected);
+ test.equal(expected, actual, message);
+}
+
+exports.inline = function(test) {
+ 'use strict';
+
+ test.expect(3);
+
+ assertFileEquality(test,
+ 'tmp/css.min.html',
+ 'test/expected/css.min.html',
+ 'Should compile css inline');
+
+ assertFileEquality(test,
+ 'tmp/img.min.html',
+ 'test/expected/img.min.html',
+ 'Should compile image inline');
+
+ assertFileEquality(test,
+ 'tmp/html.min.html',
+ 'test/expected/html.min.html',
+ 'Should compile html inline');
+
+ test.done();
+};
View
@@ -1,15 +0,0 @@
-{
- "name": "grunt-inline",
- "version": "0.1.6",
- "repository": {
- "type": "git",
- "url": "https://github.com/chyingp/grunt-inline.git"
- },
- "engines": {
- "node": ">=0.8.0"
- },
- "devDependencies": {
- "grunt": "~0.4.1",
- "grunt-inline": "~0.1.8"
- }
-}

0 comments on commit 10f1642

Please sign in to comment.