This repository has been archived by the owner on Dec 2, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactored the code base to work with this.file instead of this.files.
- Refactored the tests to make more explicit assertions.
- Loading branch information
Darío Javier Cravero
committed
Dec 10, 2012
1 parent
ca35b3c
commit cc9e0e4
Showing
8 changed files
with
106 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
test/fixtures/output/*.js | ||
test/fixtures/output/* |
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
Empty file.
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
Empty file.
Empty file.
File renamed without changes.
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,26 +1,54 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var grunt = require('grunt'); | ||
|
||
exports.md5 = { | ||
main: function(test) { | ||
test.expect(2); | ||
test.expect(1); | ||
|
||
var filenameA = require('crypto'). | ||
var md5Filename = 'test-' + require('crypto'). | ||
createHash('md5'). | ||
update(fs.readFileSync('test/fixtures/js/test-a.js', 'utf8')). | ||
update(grunt.file.read('test/fixtures/test.js')). | ||
digest('hex') + '.js'; | ||
var resultA = fs.existsSync('test/fixtures/output/'+filenameA); | ||
test.ok(resultA, 'should generate a md5 filename'); | ||
|
||
var filenameB = require('crypto'). | ||
test.ok(grunt.file.exists('test/fixtures/output/main/' + md5Filename), | ||
'should generate an MD5 filename keeping its basename and extension'); | ||
test.done(); | ||
}, | ||
noExtension: function(test) { | ||
test.expect(1); | ||
|
||
var md5Filename = 'test-' + require('crypto'). | ||
createHash('md5'). | ||
update(grunt.file.read('test/fixtures/test.js')). | ||
digest('hex'); | ||
|
||
test.ok(grunt.file.exists('test/fixtures/output/noExtension/' + md5Filename), | ||
'should generate an MD5 filename keeping only its basename'); | ||
test.done(); | ||
}, | ||
noBasename: function(test) { | ||
test.expect(1); | ||
|
||
var md5Filename = require('crypto'). | ||
createHash('md5'). | ||
update(fs.readFileSync('test/fixtures/js/test-b.js', 'utf8')). | ||
update(grunt.file.read('test/fixtures/test.js')). | ||
digest('hex') + '.js'; | ||
var resultB = fs.existsSync('test/fixtures/output/'+filenameB); | ||
test.ok(resultB, 'should generate a md5 filename'); | ||
|
||
test.ok(grunt.file.exists('test/fixtures/output/noBasename/' + md5Filename), | ||
'should generate an MD5 filename keeping only its extension'); | ||
test.done(); | ||
}, | ||
noBasenameOrExtension: function(test) { | ||
test.expect(1); | ||
|
||
var md5Filename = require('crypto'). | ||
createHash('md5'). | ||
update(grunt.file.read('test/fixtures/test.js')). | ||
digest('hex'); | ||
|
||
test.ok(grunt.file.exists('test/fixtures/output/noBasenameOrExtension/' + md5Filename), | ||
'should generate an MD5 filename without keeping its basename or extension'); | ||
test.done(); | ||
} | ||
}; |