Skip to content

Commit cd50867

Browse files
juliemrpetebacondarwin
authored andcommitted
chore(protractor-generator): add dgeni processor for protractor
1 parent 0f77bd6 commit cd50867

4 files changed

Lines changed: 54 additions & 1 deletion

File tree

docs/config/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = function(config) {
1212
require('./processors/keywords'),
1313
require('./processors/versions-data'),
1414
require('./processors/pages-data'),
15+
require('./processors/protractor-generate'),
1516
require('./processors/index-page')
1617
]);
1718

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var _ = require('lodash');
2+
var log = require('winston');
3+
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+
module.exports = {
9+
name: 'protractor-generate',
10+
description: 'Generate a protractor test file from the e2e tests in the examples',
11+
runAfter: ['adding-extra-docs'],
12+
runBefore: ['extra-docs-added'],
13+
init: function(config, injectables) {
14+
protractorFolder = config.get('rendering.protractor.outputFolder', 'ptore2e');
15+
},
16+
process: function(docs, examples) {
17+
_.forEach(examples, function(example) {
18+
19+
_.forEach(example.files, function(file) {
20+
21+
// Check if it's a Protractor test.
22+
if (!(file.type == 'protractor')) {
23+
return;
24+
}
25+
26+
// Create a new file for the test.
27+
// TODO - at the moment, only jqLite is being used. Will need to generate
28+
// another doc for jQuery if we want to test against that.
29+
var protractorDoc = {
30+
docType: 'e2e-test',
31+
id: 'protractorTest' + '-' + example.id,
32+
template: 'protractorTests.template.js',
33+
outputPath: path.join(protractorFolder, example.id, 'jqlite' + '_test.js'),
34+
innerTest: file.fileContents,
35+
pathPrefix: '.', // Hold for if we test with full jQuery
36+
exampleId: example.id,
37+
description: example.doc.id,
38+
examplePath: example.outputFolder + '/index.html'
39+
};
40+
41+
docs.push(protractorDoc);
42+
});
43+
});
44+
}
45+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
describe("{$ doc.description $}", function() {
2+
beforeEach(function() {
3+
browser.get("{$ doc.pathPrefix $}/{$ doc.examplePath $}");
4+
});
5+
6+
{$ doc.innerTest $}
7+
});

src/ng/directive/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ var inputType = {
290290
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
291291
<tt>myForm.$error.email = {{!!myForm.$error.email}}</tt><br/>
292292
</form>
293-
</file>
293+
</file>
294294
<file name="protractor.js" type="protractor">
295295
var text = element(by.binding('text'));
296296
var valid = element(by.binding('myForm.input.$valid'));

0 commit comments

Comments
 (0)