Skip to content

Commit

Permalink
增加test
Browse files Browse the repository at this point in the history
  • Loading branch information
lackhurt committed Jun 21, 2014
1 parent 2c45890 commit 5c5cf68
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 65 deletions.
23 changes: 2 additions & 21 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,13 @@ module.exports = function (grunt) {
},

// Configuration to be run (and then tested).
/*css_import: {
default_options: {
options: {
},
files: {
'tmp/default_options': ['test/fixtures/testing', 'test/fixtures/123']
}
},
custom_options: {
options: {
separator: ': ',
punctuation: ' !!!'
},
files: {
'tmp/custom_options': ['test/fixtures/testing', 'test/fixtures/123']
}
}
},*/
css_import: {
simple_concat: {
options: {

},
files: {
'tmp/all.css': ['test/fixtures/style/all.css', 'test/fixtures/style/all1.css'],
'tmp/all1.css': 'test/fixtures/style/all.css'
'tmp/simple_concat/all.css': ['test/fixtures/style/all.css']
}
}
},
Expand All @@ -75,7 +56,7 @@ module.exports = function (grunt) {

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'css_import']);
grunt.registerTask('test', ['clean', 'css_import', 'nodeunit']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);
Expand Down
71 changes: 31 additions & 40 deletions test/css_import_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,37 @@
var grunt = require('grunt');

/*
======== A Handy Little Nodeunit Reference ========
https://github.com/caolan/nodeunit
Test methods:
test.expect(numAssertions)
test.done()
Test assertions:
test.ok(value, [message])
test.equal(actual, expected, [message])
test.notEqual(actual, expected, [message])
test.deepEqual(actual, expected, [message])
test.notDeepEqual(actual, expected, [message])
test.strictEqual(actual, expected, [message])
test.notStrictEqual(actual, expected, [message])
test.throws(block, [error], [message])
test.doesNotThrow(block, [error], [message])
test.ifError(value)
*/
======== A Handy Little Nodeunit Reference ========
https://github.com/caolan/nodeunit
Test methods:
test.expect(numAssertions)
test.done()
Test assertions:
test.ok(value, [message])
test.equal(actual, expected, [message])
test.notEqual(actual, expected, [message])
test.deepEqual(actual, expected, [message])
test.notDeepEqual(actual, expected, [message])
test.strictEqual(actual, expected, [message])
test.notStrictEqual(actual, expected, [message])
test.throws(block, [error], [message])
test.doesNotThrow(block, [error], [message])
test.ifError(value)
*/

exports.css_import = {
setUp: function(done) {
// setup here if necessary
done();
},
default_options: function(test) {
test.expect(1);

var actual = grunt.file.read('tmp/default_options');
var expected = grunt.file.read('test/expected/default_options');
test.equal(actual, expected, 'should describe what the default behavior is.');

test.done();
},
custom_options: function(test) {
test.expect(1);

var actual = grunt.file.read('tmp/custom_options');
var expected = grunt.file.read('test/expected/custom_options');
test.equal(actual, expected, 'should describe what the custom option(s) behavior is.');

test.done();
},
setUp: function (done) {
// setup here if necessary
done();
},
simple_concat: function(test) {
test.expect(1);

var actual = grunt.file.read('tmp/simple_concat/all.css');
var expected = grunt.file.read('test/expected/simple_concat/all.css');
test.equal(actual, expected, 'should describe what the path option(s) behavior is not(but with path).');

test.done();
},
};
1 change: 0 additions & 1 deletion test/expected/custom_options

This file was deleted.

1 change: 0 additions & 1 deletion test/expected/default_options

This file was deleted.

34 changes: 34 additions & 0 deletions test/expected/simple_concat/all.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
h1 {

}

@import "http://module/common/form.css";

h2 {

}


.content .button{
display: inline-block;
color:#fff;
padding-left: 18px;
background: url('module/common/images/btn_all.gif') no-repeat 0px ;
padding-right:0;
}

h3 {

}

#fancybox-left, #fancybox-right {
position: absolute;
bottom: 0px;
height: 100%;
width: 35%;
cursor: pointer;
outline: none;
background: transparent url('lib/fancybox/images/blank.gif');
z-index: 10002;
display: none;
}
1 change: 0 additions & 1 deletion test/fixtures/123

This file was deleted.

15 changes: 15 additions & 0 deletions test/fixtures/style/all.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
h1 {

}
@import "http://module/common/form.css";
h2 {

}

@import "module/common/button.css";
h3 {

}
@import "lib/fancybox/fancybox.css";
@import "module/module_a/module_a.css";

11 changes: 11 additions & 0 deletions test/fixtures/style/lib/fancybox/fancybox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#fancybox-left, #fancybox-right {
position: absolute;
bottom: 0px;
height: 100%;
width: 35%;
cursor: pointer;
outline: none;
background: transparent url('images/blank.gif');
z-index: 10002;
display: none;
}
Binary file added test/fixtures/style/lib/fancybox/images/blank.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions test/fixtures/style/module/common/button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.content .button{
display: inline-block;
color:#fff;
padding-left: 18px;
background: url(images/btn_all.gif) no-repeat 0px ;
padding-right:0;
}
11 changes: 11 additions & 0 deletions test/fixtures/style/module/common/form.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.form {
background: none;
border: none;
background: url('images/btn_input_search.gif') no-repeat;
height: 34px;
width: 64px;
color: #fff;
font-size: 14px;
cursor: pointer;
vertical-align: middle;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/fixtures/style/module/common/images/form.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions test/fixtures/style/module/module_a/module_a.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

.login_inputWrap{
background: url(/img/text.jpg) no-repeat 0px 0px;
display: inline-block;
}

.test {
background-image: url(/img/text.jpg);
}

.test-absolute-path {
background: url('http://test.com/test.jpg');

}
1 change: 0 additions & 1 deletion test/fixtures/testing

This file was deleted.

0 comments on commit 5c5cf68

Please sign in to comment.