1- var should = require ( "should" ) ;
2- var sinon = require ( "sinon" ) ;
3- var TemplatePluginEnvironment = require ( "./helpers/TemplatePluginEnvironment" ) ;
4- var ConcatSource = require ( "webpack-sources" ) . ConcatSource ;
5- var AmdMainTemplatePlugin = require ( "../lib/AmdMainTemplatePlugin" ) ;
6-
7- describe ( "AmdMainTemplatePlugin" , function ( ) {
8- var env ;
9-
10- var applyTemplatePluginWithOptions = function ( Plugin , name ) {
11- var plugin = new Plugin ( name ) ;
12- var templatePluginEnvironment = new TemplatePluginEnvironment ( ) ;
13- var environment = templatePluginEnvironment . getEnvironmentStub ( ) ;
1+ "use strict" ;
2+
3+ const should = require ( "should" ) ;
4+ const sinon = require ( "sinon" ) ;
5+ const TemplatePluginEnvironment = require ( "./helpers/TemplatePluginEnvironment" ) ;
6+ const ConcatSource = require ( "webpack-sources" ) . ConcatSource ;
7+ const AmdMainTemplatePlugin = require ( "../lib/AmdMainTemplatePlugin" ) ;
8+
9+ describe ( "AmdMainTemplatePlugin" , ( ) => {
10+ let env ;
11+
12+ const applyTemplatePluginWithOptions = function ( Plugin , name ) {
13+ const plugin = new Plugin ( name ) ;
14+ const templatePluginEnvironment = new TemplatePluginEnvironment ( ) ;
15+ const environment = templatePluginEnvironment . getEnvironmentStub ( ) ;
1416 environment . mainTemplate . applyPluginsWaterfall = ( ) => "templateName" ;
1517 plugin . apply ( environment ) ;
16- return templatePluginEnvironment
18+ return templatePluginEnvironment ;
1719 } ;
1820
19- var setupPluginAndGetEventBinding = function ( name ) {
20- var templatePlugin = applyTemplatePluginWithOptions ( AmdMainTemplatePlugin , name ) ;
21- var eventBindings = templatePlugin . getEventBindings ( ) ;
21+ const setupPluginAndGetEventBinding = function ( name ) {
22+ const templatePlugin = applyTemplatePluginWithOptions ( AmdMainTemplatePlugin , name ) ;
23+ const eventBindings = templatePlugin . getEventBindings ( ) ;
2224 return eventBindings [ 0 ] ;
2325 } ;
2426
25- beforeEach ( function ( ) {
27+ beforeEach ( ( ) => {
2628 env = {
2729 modulesListWithExternals : [ {
2830 id : "module-1" ,
@@ -48,118 +50,97 @@ describe("AmdMainTemplatePlugin", function() {
4850 } ;
4951 } ) ;
5052
51- it ( "has apply function" , function ( ) {
52- ( new AmdMainTemplatePlugin ( ) ) . apply . should . be . a . Function ( ) ;
53- } ) ;
53+ it ( "has apply function" , ( ) => new AmdMainTemplatePlugin ( ) . apply . should . be . a . Function ( ) ) ;
5454
55- describe ( "when applied" , function ( ) {
56- beforeEach ( function ( ) {
57- env . templatePlugin = applyTemplatePluginWithOptions ( AmdMainTemplatePlugin , "foo" ) ;
58- } ) ;
55+ describe ( "when applied" , ( ) => {
56+ beforeEach ( ( ) =>
57+ env . templatePlugin = applyTemplatePluginWithOptions ( AmdMainTemplatePlugin , "foo" ) ) ;
5958
60- describe ( "event handlers" , function ( ) {
61- beforeEach ( function ( ) {
62- env . eventBindings = env . templatePlugin . getEventBindings ( ) ;
63- } ) ;
59+ describe ( "event handlers" , ( ) => {
60+ beforeEach ( ( ) => env . eventBindings = env . templatePlugin . getEventBindings ( ) ) ;
6461
65- it ( "binds one handlers" , function ( ) {
66- env . eventBindings . length . should . be . exactly ( 1 ) ;
67- } ) ;
62+ it ( "binds one handlers" , ( ) => env . eventBindings . length . should . be . exactly ( 1 ) ) ;
6863
69- describe ( "render-with-entry handler" , function ( ) {
70- beforeEach ( function ( ) {
71- env . eventBinding = env . eventBindings [ 0 ] ;
72- } ) ;
64+ describe ( "render-with-entry handler" , ( ) => {
65+ beforeEach ( ( ) => env . eventBinding = env . eventBindings [ 0 ] ) ;
7366
74- it ( "binds to render-with-entry event" , function ( ) {
75- env . eventBinding . name . should . be . exactly ( "render-with-entry" ) ;
76- } ) ;
67+ it ( "binds to render-with-entry event" , ( ) =>
68+ env . eventBinding . name . should . be . exactly ( "render-with-entry" ) ) ;
7769
78- describe ( "with name" , function ( ) {
79- beforeEach ( function ( ) {
70+ describe ( "with name" , ( ) => {
71+ beforeEach ( ( ) => {
8072 env . chunk = {
8173 modules : env . modulesListWithExternals
8274 } ;
8375 env . eventBinding = setupPluginAndGetEventBinding ( "foo" ) ;
8476 } ) ;
8577
86- it ( "creates source wrapper with module name and external dependencies" , function ( ) {
87- var source = env . eventBinding . handler ( "moduleSource()" , env . chunk , "bar" ) ;
78+ it ( "creates source wrapper with module name and external dependencies" , ( ) => {
79+ const source = env . eventBinding . handler ( "moduleSource()" , env . chunk , "bar" ) ;
8880 source . should . be . instanceof ( ConcatSource ) ;
8981 source . source ( ) . should . be . exactly ( 'define("templateName", ["external-amd-module","external-non-amd-module",null], function(__WEBPACK_EXTERNAL_MODULE_module-1__, __WEBPACK_EXTERNAL_MODULE_module-2__, __WEBPACK_EXTERNAL_MODULE_module-3__) { return moduleSource()});' ) ;
9082 } ) ;
9183 } ) ;
9284
93- describe ( "with external dependencies" , function ( ) {
94- beforeEach ( function ( ) {
85+ describe ( "with external dependencies" , ( ) => {
86+ beforeEach ( ( ) => {
9587 env . chunk = {
9688 modules : env . modulesListWithExternals
9789 } ;
9890 env . eventBinding = setupPluginAndGetEventBinding ( ) ;
9991 } ) ;
10092
101- it ( "creates source wrapper with external dependencies" , function ( ) {
102- var source = env . eventBinding . handler ( "moduleSource()" , env . chunk , "bar" ) ;
93+ it ( "creates source wrapper with external dependencies" , ( ) => {
94+ const source = env . eventBinding . handler ( "moduleSource()" , env . chunk , "bar" ) ;
10395 source . should . be . instanceof ( ConcatSource ) ;
10496 source . source ( ) . should . be . exactly ( 'define(["external-amd-module","external-non-amd-module",null], function(__WEBPACK_EXTERNAL_MODULE_module-1__, __WEBPACK_EXTERNAL_MODULE_module-2__, __WEBPACK_EXTERNAL_MODULE_module-3__) { return moduleSource()});' ) ;
10597 } ) ;
10698 } ) ;
10799
108- describe ( "with only local dependencies" , function ( ) {
109- beforeEach ( function ( ) {
110- var externalFlag = {
100+ describe ( "with only local dependencies" , ( ) => {
101+ beforeEach ( ( ) => {
102+ const externalFlag = {
111103 external : false
112104 } ;
113- var noExternals = env . modulesListWithExternals . map ( ( module ) => Object . assign ( module , externalFlag ) ) ;
105+ const noExternals = env . modulesListWithExternals . map ( ( module ) => Object . assign ( module , externalFlag ) ) ;
114106 env . chunk = {
115107 modules : noExternals
116108 } ;
117109 env . eventBinding = setupPluginAndGetEventBinding ( ) ;
118110 } ) ;
119111
120- it ( "creates source wrapper with callback only" , function ( ) {
121- var source = env . eventBinding . handler ( "moduleSource()" , env . chunk , "bar" ) ;
112+ it ( "creates source wrapper with callback only" , ( ) => {
113+ const source = env . eventBinding . handler ( "moduleSource()" , env . chunk , "bar" ) ;
122114 source . should . be . instanceof ( ConcatSource ) ;
123115 source . source ( ) . should . be . exactly ( 'define(function() { return moduleSource()});' ) ;
124116 } ) ;
125117 } ) ;
126118 } ) ;
127119 } ) ;
128120
129- describe ( "main template event handlers" , function ( ) {
130- beforeEach ( function ( ) {
131- env . mainTemplateBindings = env . templatePlugin . getMainTemplateBindings ( ) ;
132- } ) ;
121+ describe ( "main template event handlers" , ( ) => {
122+ beforeEach ( ( ) =>
123+ env . mainTemplateBindings = env . templatePlugin . getMainTemplateBindings ( ) ) ;
133124
134- it ( "binds two handlers" , function ( ) {
135- env . mainTemplateBindings . length . should . be . exactly ( 2 ) ;
136- } ) ;
125+ it ( "binds two handlers" , ( ) => env . mainTemplateBindings . length . should . be . exactly ( 2 ) ) ;
137126
138- describe ( "global-hash-paths handler" , function ( ) {
139- beforeEach ( function ( ) {
140- env . mainTemplateBinding = env . mainTemplateBindings [ 0 ] ;
141- } ) ;
127+ describe ( "global-hash-paths handler" , ( ) => {
128+ beforeEach ( ( ) => env . mainTemplateBinding = env . mainTemplateBindings [ 0 ] ) ;
142129
143- it ( "binds to global-hash-paths event" , function ( ) {
144- env . mainTemplateBinding . name . should . be . exactly ( "global-hash-paths" ) ;
145- } ) ;
130+ it ( "binds to global-hash-paths event" , ( ) =>
131+ env . mainTemplateBinding . name . should . be . exactly ( "global-hash-paths" ) ) ;
146132
147- it ( "adds name to path array" , function ( ) {
148- env . mainTemplateBinding . handler ( [ ] ) . should . deepEqual ( [ "foo" ] ) ;
149- } ) ;
133+ it ( "adds name to path array" , ( ) =>
134+ env . mainTemplateBinding . handler ( [ ] ) . should . deepEqual ( [ "foo" ] ) ) ;
150135 } ) ;
151136
152- describe ( "hash handler" , function ( ) {
153- beforeEach ( function ( ) {
154- env . mainTemplateBinding = env . mainTemplateBindings [ 1 ] ;
155- } ) ;
137+ describe ( "hash handler" , ( ) => {
138+ beforeEach ( ( ) => env . mainTemplateBinding = env . mainTemplateBindings [ 1 ] ) ;
156139
157- it ( "binds to hash event" , function ( ) {
158- env . mainTemplateBinding . name . should . be . exactly ( "hash" ) ;
159- } ) ;
140+ it ( "binds to hash event" , ( ) => env . mainTemplateBinding . name . should . be . exactly ( "hash" ) ) ;
160141
161- it ( "updates hash" , function ( ) {
162- var hash = {
142+ it ( "updates hash" , ( ) => {
143+ const hash = {
163144 update : sinon . spy ( )
164145 } ;
165146 env . mainTemplateBinding . handler ( hash ) ;
0 commit comments