Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Filirom1
committed
Jun 18, 2012
1 parent
29d589c
commit 2107d0b
Showing
5 changed files
with
83 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
var Path = require('path'), | ||
fs = require('fs'), | ||
b64 = require('..'); | ||
|
||
require('should'); | ||
|
||
describe('A tricky CSS', function(){ | ||
describe('A complex CSS', function(){ | ||
var cssFile = Path.join(__dirname, 'fixture', 'css', 'style.css'), | ||
relative = Path.join(__dirname, 'fixture', 'css'); | ||
root = Path.join(__dirname, 'fixture'); | ||
it('should be optimized with base64', function(done){ | ||
b64(cssFile, root, function(err, css){ | ||
css.should.include(".single-quote {\n background: url('data:image/gif;base64,"); | ||
css.should.include(".double-quote {\n background: url(\"data:image/gif;base64,"); | ||
css.should.include(".absolute {\n background: url('data:image/gif;base64,"); | ||
|
||
css.should.include(".external {\n background: url('http"); | ||
css.should.include(".tooBig {\n background: url('../img"); | ||
css.should.include(".not-found {\n background: url('../img"); | ||
it('a file should be optimized with base64', function(done){ | ||
b64.fromFile(cssFile, root, function(err, css){ | ||
cssShouldBeCorrect(css); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('a string should be optimized with base64', function(done){ | ||
var css = fs.readFileSync(cssFile); | ||
b64.fromString(css, relative, root, function(err, css){ | ||
cssShouldBeCorrect(css); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
function cssShouldBeCorrect(css){ | ||
css.should.include(".single-quote {\n background: url('data:image/gif;base64,"); | ||
css.should.include(".double-quote {\n background: url(\"data:image/gif;base64,"); | ||
css.should.include(".absolute {\n background: url('data:image/gif;base64,"); | ||
|
||
css.should.include(".external {\n background: url('http"); | ||
css.should.include(".tooBig {\n background: url('../img"); | ||
css.should.include(".not-found {\n background: url('../img"); | ||
} |