-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
58 lines (47 loc) · 1.44 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* eslint-env mocha */
// 'use strict'
var assert = require('assert')
var gutil = require('gulp-util')
// var path = require('path')
var revFormat = require('./')
var sampleFile1 = new gutil.File({
cwd: __dirname,
base: __dirname,
contents: new Buffer('')
})
var sampleFile2 = new gutil.File({
cwd: __dirname,
base: __dirname,
contents: new Buffer('')
})
sampleFile1.revOrigPath = 'unicorn.css'
sampleFile1.revHash = 'd41d8cd98f'
sampleFile2.revOrigPath = 'unicorn.ext1.ext2.ext3.js'
sampleFile2.revHash = 'd41d8cd98f'
it('should format hash for revved files', function (cb) {
var stream = revFormat({prefix: '--', suffix: '__'})
stream.on('data', function (file) {
assert.equal(file.path, 'unicorn--d41d8cd98f__.css')
assert.equal(file.revOrigPath, 'unicorn.css')
cb()
})
stream.write(sampleFile1)
})
it('should add formatted hash before last extension', function (cb) {
var stream = revFormat({lastExt: true})
stream.on('data', function (file) {
assert.equal(file.path, 'unicorn.ext1.ext2.ext3-d41d8cd98f.js')
assert.equal(file.revOrigPath, 'unicorn.ext1.ext2.ext3.js')
cb()
})
stream.write(sampleFile2)
})
it('should keep gulp-rev format by default', function (cb) {
var stream = revFormat()
stream.on('data', function (file) {
assert.equal(file.path, 'unicorn-d41d8cd98f.ext1.ext2.ext3.js')
assert.equal(file.revOrigPath, 'unicorn.ext1.ext2.ext3.js')
cb()
})
stream.write(sampleFile2)
})