diff options
| -rw-r--r-- | docs/config/index.js | 1 | ||||
| -rw-r--r-- | docs/config/processors/protractor-generate.js | 45 | ||||
| -rw-r--r-- | docs/config/templates/protractorTests.template.js | 7 | ||||
| -rw-r--r-- | src/ng/directive/input.js | 2 | 
4 files changed, 54 insertions, 1 deletions
| diff --git a/docs/config/index.js b/docs/config/index.js index ae905889..eb23737e 100644 --- a/docs/config/index.js +++ b/docs/config/index.js @@ -12,6 +12,7 @@ module.exports = function(config) {      require('./processors/keywords'),      require('./processors/versions-data'),      require('./processors/pages-data'), +    require('./processors/protractor-generate'),      require('./processors/index-page')    ]); diff --git a/docs/config/processors/protractor-generate.js b/docs/config/processors/protractor-generate.js new file mode 100644 index 00000000..39c79212 --- /dev/null +++ b/docs/config/processors/protractor-generate.js @@ -0,0 +1,45 @@ +var _ = require('lodash'); +var log = require('winston'); +var path = require('canonical-path'); +var trimIndentation = require('dgeni/lib/utils/trim-indentation'); +var code = require('dgeni/lib/utils/code'); +var protractorFolder; + +module.exports = { +  name: 'protractor-generate', +  description: 'Generate a protractor test file from the e2e tests in the examples', +  runAfter: ['adding-extra-docs'], +  runBefore: ['extra-docs-added'], +  init: function(config, injectables) { +    protractorFolder = config.get('rendering.protractor.outputFolder', 'ptore2e'); +  }, +  process: function(docs, examples) { +    _.forEach(examples, function(example) { + +      _.forEach(example.files, function(file) { + +        // Check if it's a Protractor test. +        if (!(file.type == 'protractor')) { +          return; +        } + +        // Create a new file for the test. +        // TODO - at the moment, only jqLite is being used. Will need to generate +        // another doc for jQuery if we want to test against that. +        var protractorDoc = { +          docType: 'e2e-test', +          id: 'protractorTest' + '-' + example.id, +          template: 'protractorTests.template.js', +          outputPath: path.join(protractorFolder, example.id, 'jqlite' + '_test.js'), +          innerTest: file.fileContents, +          pathPrefix: '.', // Hold for if we test with full jQuery +          exampleId: example.id, +          description: example.doc.id, +          examplePath: example.outputFolder + '/index.html' +        }; + +        docs.push(protractorDoc); +      }); +    }); +  } +}; diff --git a/docs/config/templates/protractorTests.template.js b/docs/config/templates/protractorTests.template.js new file mode 100644 index 00000000..d7580a48 --- /dev/null +++ b/docs/config/templates/protractorTests.template.js @@ -0,0 +1,7 @@ +describe("{$ doc.description $}", function() { +  beforeEach(function() { +    browser.get("{$ doc.pathPrefix $}/{$ doc.examplePath $}"); +  }); + +{$ doc.innerTest $}   +}); diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 0e7eb6d8..676c1692 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -290,7 +290,7 @@ var inputType = {               <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>               <tt>myForm.$error.email = {{!!myForm.$error.email}}</tt><br/>             </form> -        </file> +         </file>          <file name="protractor.js" type="protractor">            var text = element(by.binding('text'));            var valid = element(by.binding('myForm.input.$valid')); | 
