File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -47,4 +47,8 @@ module.exports = class RawModule extends Module {
47
47
return new RawSource ( this . sourceStr ) ;
48
48
}
49
49
50
+ updateHash ( hash ) {
51
+ hash . update ( this . sourceStr ) ;
52
+ super . updateHash ( hash ) ;
53
+ }
50
54
} ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const RawSource = require("webpack-sources").RawSource;
6
6
const RequestShortener = require ( "../lib/RequestShortener" ) ;
7
7
const should = require ( "should" ) ;
8
8
const path = require ( "path" ) ;
9
+ const crypto = require ( "crypto" ) ;
9
10
10
11
describe ( "RawModule" , ( ) => {
11
12
let myRawModule ;
@@ -62,4 +63,18 @@ describe("RawModule", () => {
62
63
}
63
64
) ;
64
65
} ) ;
66
+
67
+ describe ( "updateHash" , ( ) => {
68
+ it ( "should include sourceStr in its hash" , ( ) => {
69
+ const hashModule = ( module ) => {
70
+ const hash = crypto . createHash ( "sha256" ) ;
71
+ module . updateHash ( hash ) ;
72
+ return hash . digest ( "hex" ) ;
73
+ } ;
74
+
75
+ const hashFoo = hashModule ( new RawModule ( "\"foo\"" ) ) ;
76
+ const hashBar = hashModule ( new RawModule ( "\"bar\"" ) ) ;
77
+ hashFoo . should . not . equal ( hashBar ) ;
78
+ } ) ;
79
+ } ) ;
65
80
} ) ;
You can’t perform that action at this time.
0 commit comments