@@ -52,17 +52,24 @@ describe('git-revision-webpack-plugin (integration)', function () {
5252 expect ( COMMITHASH . toString ( ) ) . to . eql ( '9a15b3ba1f8c347f9db94bcfde9630ed4fdeb1b2' )
5353 } )
5454
55- describe ( '[git-revision-version] and [git-revision-hash] templates' , function ( ) {
55+ it ( 'should create the BRANCH file' , function ( ) {
56+ var branchPath = path . join ( targetBuild , 'BRANCH' )
57+ var BRANCH = fs . readFileSync ( branchPath )
58+
59+ expect ( BRANCH . toString ( ) ) . to . eql ( 'master' )
60+ } )
61+
62+ describe ( '[git-revision-version], [git-revision-hash] and [git-revision-branch] templates' , function ( ) {
5663 it ( 'should support templates in the output.filename' , function ( ) {
57- var versionPath = path . join ( targetBuild , 'main-v1.0.0-1-g9a15b3b.js' )
64+ var versionPath = path . join ( targetBuild , 'main-master- v1.0.0-1-g9a15b3b.js' )
5865 fs . readFileSync ( versionPath )
5966 } )
6067
6168 it ( 'should support setting the public path' , function ( ) {
62- var versionPath = path . join ( targetBuild , 'main-v1.0.0-1-g9a15b3b.js' )
69+ var versionPath = path . join ( targetBuild , 'main-master- v1.0.0-1-g9a15b3b.js' )
6370 var mainJs = fs . readFileSync ( versionPath )
6471
65- var expectedPublicPath = '__webpack_require__.p = "http://cdn.com/assets/v1.0.0-1-g9a15b3b/9a15b3ba1f8c347f9db94bcfde9630ed4fdeb1b2";'
72+ var expectedPublicPath = '__webpack_require__.p = "http://cdn.com/assets/master/ v1.0.0-1-g9a15b3b/9a15b3ba1f8c347f9db94bcfde9630ed4fdeb1b2";'
6673
6774 expect ( mainJs . indexOf ( expectedPublicPath ) !== - 1 ) . to . eql ( true )
6875 } )
@@ -78,6 +85,11 @@ describe('git-revision-webpack-plugin (integration)', function () {
7885 var plugin = new GitRevisionPlugin ( { gitWorkTree : targetProject } )
7986 expect ( plugin . version ( ) ) . to . eql ( 'v1.0.0-1-g9a15b3b' )
8087 } )
88+
89+ it ( 'should expose the branch' , ( ) => {
90+ var plugin = new GitRevisionPlugin ( { gitWorkTree : targetProject } )
91+ expect ( plugin . branch ( ) ) . to . eql ( 'master' )
92+ } )
8193 } )
8294} )
8395
@@ -118,17 +130,24 @@ describe('git-revision-webpack-plugin with lightweightTags option', function ()
118130 expect ( COMMITHASH . toString ( ) ) . to . eql ( '9a15b3ba1f8c347f9db94bcfde9630ed4fdeb1b2' )
119131 } )
120132
121- describe ( '[git-revision-version] and [git-revision-hash] templates' , function ( ) {
133+ it ( 'should create the BRANCH file' , function ( ) {
134+ var branchPath = path . join ( targetBuild , 'BRANCH' )
135+ var BRANCH = fs . readFileSync ( branchPath )
136+
137+ expect ( BRANCH . toString ( ) ) . to . eql ( 'master' )
138+ } )
139+
140+ describe ( '[git-revision-version], [git-revision-hash] and [git-revision-branch] templates' , function ( ) {
122141 it ( 'should support templates in the output.filename' , function ( ) {
123- var versionPath = path . join ( targetBuild , 'main-v2.0.0-beta.js' )
142+ var versionPath = path . join ( targetBuild , 'main-master- v2.0.0-beta.js' )
124143 fs . readFileSync ( versionPath )
125144 } )
126145
127146 it ( 'should support setting the public path' , function ( ) {
128- var versionPath = path . join ( targetBuild , 'main-v2.0.0-beta.js' )
147+ var versionPath = path . join ( targetBuild , 'main-master- v2.0.0-beta.js' )
129148 var mainJs = fs . readFileSync ( versionPath )
130149
131- var expectedPublicPath = '__webpack_require__.p = "http://cdn.com/assets/v2.0.0-beta/9a15b3ba1f8c347f9db94bcfde9630ed4fdeb1b2";'
150+ var expectedPublicPath = '__webpack_require__.p = "http://cdn.com/assets/master/ v2.0.0-beta/9a15b3ba1f8c347f9db94bcfde9630ed4fdeb1b2";'
132151
133152 expect ( mainJs . indexOf ( expectedPublicPath ) !== - 1 ) . to . eql ( true )
134153 } )
@@ -144,6 +163,10 @@ describe('git-revision-webpack-plugin with lightweightTags option', function ()
144163 var plugin = new GitRevisionPlugin ( { gitWorkTree : targetProject , lightweightTags : true } )
145164 expect ( plugin . version ( ) ) . to . eql ( 'v2.0.0-beta' )
146165 } )
166+
167+ it ( 'should expose the branch' , ( ) => {
168+ var plugin = new GitRevisionPlugin ( { gitWorkTree : targetProject , lightweightTags : true } )
169+ expect ( plugin . branch ( ) ) . to . eql ( 'master' )
170+ } )
147171 } )
148172} )
149-
0 commit comments