Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
chore(typings): remove ptor from gulp types (#3307)
Browse files Browse the repository at this point in the history
- after investigation, variables in the namespace cannot be assigned a value
- types will require import of the classes and then setting the value from global

  ```
  import {Browser} from 'protractor';
  var browser: Browser = global['browser'];
  ```

- update typing tests to set the value of the type
  • Loading branch information
cnishina authored Jun 28, 2016
1 parent f018aa0 commit 5dab402
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
8 changes: 6 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ gulp.task('default',['prepublish']);

gulp.task('types', function(done) {
var folder = 'built';
var files = ['ptor', 'browser', 'element', 'locators', 'expectedConditions'];
var files = ['browser', 'element', 'locators', 'expectedConditions'];
var outputFile = path.resolve(folder, 'index.d.ts');
var contents = '';
contents += 'declare namespace protractor {\n';
files.forEach(file => {
contents += parseTypingsFile(folder, file);
});
contents += '}\n';

// add module declaration
contents += 'declare module "protractor" {\n';
Expand All @@ -104,6 +106,9 @@ var parseTypingsFile = function(folder, file) {
if (line.indexOf('export') !== -1) {
line = line.replace('export', '').trim();
}
if (line.indexOf('declare') !== -1) {
line = line.replace('declare', '').trim();
}

// Remove webdriver types and plugins for now
line = removeTypes(line,'webdriver.ActionSequence');
Expand All @@ -115,7 +120,6 @@ var parseTypingsFile = function(folder, file) {
line = removeTypes(line,'Plugins');
contents += line + '\n';
}

}
return contents;
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/typings_tests/test_fail_browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference path="../../built/index.d.ts" />
import {browser} from 'protractor';
import {Browser} from 'protractor';
let browser: Browser;
browser.getProcessedConfig(0);
browser.getProcessedConfig('1');
browser.getProcessedConfig(true);
Expand Down
4 changes: 3 additions & 1 deletion scripts/typings_tests/test_fail_by.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference path="../../built/index.d.ts" />
import {by, By} from 'protractor';
import {ProtractorBy} from 'protractor';
let by: ProtractorBy;
let By: ProtractorBy;
by.addLocator(0, () => {});
by.addLocator(() => {}, () => {});
by.addLocator('', () => {}, () => {});
Expand Down
6 changes: 5 additions & 1 deletion scripts/typings_tests/test_fail_elements.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/// <reference path="../../built/index.d.ts" />
import {element, by, $, $$} from 'protractor';
import {ElementArrayFinder, ElementFinder, ElementHelper, ProtractorBy} from 'protractor';
let element: ElementHelper;
let by: ProtractorBy;
let $: (search: string) => ElementFinder;
let $$: (search: string) => ElementArrayFinder;
element.all(by.css('')).clone('clone');
element.all(by.css('')).clone(1);
element.all(by.css('')).clone(false);
Expand Down
3 changes: 2 additions & 1 deletion scripts/typings_tests/test_fail_expected_conditions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference path="../../built/index.d.ts" />
import {element, by, ExpectedConditions} from 'protractor';
import {ExpectedConditions_} from 'protractor';
let ExpectedConditions: ExpectedConditions_;
ExpectedConditions.not(0);
ExpectedConditions.not('1');
ExpectedConditions.not(true);
Expand Down
9 changes: 8 additions & 1 deletion scripts/typings_tests/test_pass.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/// <reference path="../../built/index.d.ts" />
import {browser, element, by, By, $, $$, ExpectedConditions} from 'protractor';
import {Browser, ElementArrayFinder, ElementFinder, ElementHelper, ExpectedConditions_, ProtractorBy} from 'protractor';
let browser: Browser;
let by: ProtractorBy;
let By: ProtractorBy;
let element: ElementHelper;
let $: (search: string) => ElementFinder;
let $$: (search: string) => ElementArrayFinder;
let ExpectedConditions: ExpectedConditions_;
element.all(by.css('')).clone();
element.all(by.css('')).then(() => {}, () => {}); // this is not appearing on the website
element.all(by.css('')).filter(() => {});
Expand Down
8 changes: 4 additions & 4 deletions scripts/typings_tests/test_typings.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ var testPassing = function(file) {


// The tests:
testFailures('test_fail_elements.ts', 3, 478);
testFailures('test_fail_browser.ts', 3, 93);
testFailures('test_fail_expected_conditions.ts', 3, 24);
testFailures('test_fail_by.ts', 3, 207);
testFailures('test_fail_browser.ts', 4, 94);
testFailures('test_fail_by.ts', 5, 209);
testFailures('test_fail_elements.ts', 7, 482);
testFailures('test_fail_expected_conditions.ts', 4, 25);
testPassing('test_pass.ts');

// Test evaluation and exiting:
Expand Down

0 comments on commit 5dab402

Please sign in to comment.