1
1
var _ = require ( 'lodash' ) ;
2
- var log = require ( 'winston' ) ;
3
2
var path = require ( 'canonical-path' ) ;
4
- var trimIndentation = require ( 'dgeni/lib/utils/trim-indentation' ) ;
5
- var code = require ( 'dgeni/lib/utils/code' ) ;
6
- var protractorFolder ;
7
-
8
- function createProtractorDoc ( example , file , env ) {
9
- var protractorDoc = {
10
- docType : 'e2e-test' ,
11
- id : 'protractorTest' + '-' + example . id ,
12
- template : 'protractorTests.template.js' ,
13
- outputPath : path . join ( protractorFolder , example . id , env + '_test.js' ) ,
14
- innerTest : file . fileContents ,
15
- pathPrefix : '.' , // Hold for if we test with full jQuery
16
- exampleId : example . id ,
17
- description : example . doc . id
18
- } ;
19
-
20
- if ( env === 'jquery' ) {
21
- protractorDoc . examplePath = example . outputFolder + '/index-jquery.html'
22
- } else {
23
- protractorDoc . examplePath = example . outputFolder + '/index.html'
24
- }
25
- return protractorDoc ;
26
- }
27
3
28
4
module . exports = {
29
5
name : 'protractor-generate' ,
30
6
description : 'Generate a protractor test file from the e2e tests in the examples' ,
31
7
runAfter : [ 'adding-extra-docs' ] ,
32
8
runBefore : [ 'extra-docs-added' ] ,
33
- init : function ( config , injectables ) {
34
- protractorFolder = config . get ( 'rendering.protractor.outputFolder' , 'ptore2e' ) ;
35
- } ,
36
- process : function ( docs , examples ) {
9
+ process : function ( docs , examples , config ) {
10
+ var protractorFolder = config . get ( 'rendering.protractor.outputFolder' , 'ptore2e' ) ;
11
+
37
12
_ . forEach ( examples , function ( example ) {
38
13
39
14
_ . forEach ( example . files , function ( file ) {
40
15
41
16
// Check if it's a Protractor test.
42
- if ( ! ( file . type == 'protractor' ) ) {
17
+ if ( file . type ! == 'protractor' ) {
43
18
return ;
44
19
}
45
20
@@ -48,5 +23,27 @@ module.exports = {
48
23
docs . push ( createProtractorDoc ( example , file , 'jqlite' ) ) ;
49
24
} ) ;
50
25
} ) ;
26
+
27
+ function createProtractorDoc ( example , file , env ) {
28
+ var protractorDoc = {
29
+ docType : 'e2e-test' ,
30
+ id : 'protractorTest' + '-' + example . id ,
31
+ template : 'protractorTests.template.js' ,
32
+ outputPath : path . join ( protractorFolder , example . id , env + '_test.js' ) ,
33
+ innerTest : file . fileContents ,
34
+ pathPrefix : '.' , // Hold for if we test with full jQuery
35
+ exampleId : example . id ,
36
+ description : example . doc . id
37
+ } ;
38
+
39
+ if ( env === 'jquery' ) {
40
+ protractorDoc . examplePath = example . outputFolder + '/index-jquery.html' ;
41
+ } else {
42
+ protractorDoc . examplePath = example . outputFolder + '/index.html' ;
43
+ }
44
+ return protractorDoc ;
45
+ }
46
+
47
+
51
48
}
52
49
} ;
0 commit comments