Skip to content

Commit 4c0b3f9

Browse files
test(hashmap): extract the hashmap fixtures
Make tests more robusts as there is a test in Gruntfile and should help the PR yeoman#38
1 parent a383f1a commit 4c0b3f9

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Gruntfile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ module.exports = function (grunt) {
8686
]);
8787

8888
grunt.registerTask('checkSummary', 'Check that summary attribute is correctly created', function () {
89+
var hashes = grunt.file.readJSON('test/hashes.json');
8990
var src = path.normalize('test/fixtures/file.png');
90-
var expected = path.normalize('test/tmp/file.26365248.png');
91+
var expected = path.normalize(hashes['test/fixtures/file.png']);
9192
assert.equal(grunt.filerev.summary[src], expected);
9293
});
9394
};

test/hashes.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"test/fixtures/file.png": "test/tmp/file.26365248.png",
3+
"test/fixtures/cfgfile.png": "test/tmp/cfgfile.da63.png",
4+
"test/fixtures/math.js": "test/tmp/withSourceMaps/math.2f56179e.js",
5+
"test/fixtures/math.js.map": "test/tmp/withSourceMaps/math.2f56179e.js.map",
6+
"test/fixtures/physics.js": "test/tmp/withSourceMaps/physics.14a0a482.js"
7+
}

test/test.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
var fs = require('fs');
33
var assert = require('assert');
44

5-
var hashes = {
6-
'test/fixtures/file.png' : 'test/tmp/file.26365248.png',
7-
'test/fixtures/cfgfile.png' : 'test/tmp/cfgfile.da63.png',
8-
'test/fixtures/math.js' : 'test/tmp/withSourceMaps/math.2f56179e.js',
9-
'test/fixtures/math.js.map' : 'test/tmp/withSourceMaps/math.2f56179e.js.map',
10-
'test/fixtures/physics.js' : 'test/tmp/withSourceMaps/physics.14a0a482.js'
11-
};
5+
var hashes = require('./hashes.json');
126

137
it('should revision files based on content', function () {
148
var file = 'test/fixtures/file.png';
@@ -51,4 +45,3 @@ it('should revision .js file ok without any .map', function () {
5145
var revisioned = fs.statSync(hashes[file]).size;
5246
assert(revisioned === original);
5347
});
54-

0 commit comments

Comments
 (0)