diff --git a/cucumber/cucumber-tests.ts b/cucumber/cucumber-tests.ts
index d6ada278c2..9f22e3f75d 100644
--- a/cucumber/cucumber-tests.ts
+++ b/cucumber/cucumber-tests.ts
@@ -1,24 +1,26 @@
///
+///
function StepSample() {
type Callback = cucumber.CallbackStepDefinition;
+ type Table = cucumber.TableDefinition;
var step = this;
var hook = this;
-
+
hook.Before(function(scenario, callback){
scenario.isFailed() && callback.pending();
})
-
+
hook.Around(function(scenario, runScenario) {
scenario.isFailed() && runScenario(null, function(){
console.log('finish tasks');
});
});
-
+
hook.registerHandler('AfterFeatures', function (event, callback) {
callback();
});
-
+
step.Given(/^I am on the Cucumber.js GitHub repository$/, function(callback:Callback) {
this.visit('https://github.com/cucumber/cucumber-js', callback);
});
@@ -36,5 +38,43 @@ function StepSample() {
callback(new Error("Expected to be on page with title " + title));
}
});
+
+ // Type for data_table.js on
+ // https://github.com/cucumber/cucumber-js/blob/a5fd8251918c278ab2e389226d165cedb44df14a/lib/cucumber/ast/data_table.js
+
+ step.Given(/^a table step with Table raw$/, function(table:Table){
+ var expected = [
+ ['Cucumber', 'Cucumis sativus'],
+ ['Burr Gherkin', 'Cucumis anguria']
+ ];
+
+ assert.deepEqual(table.raw(), expected);
+ });
+
+ step.Given(/^a table step with Table rows$/, function(table: Table){
+ var expected = [
+ ['Apricot', '5'],
+ ['Brocolli', '2'],
+ ['Cucumber', '10']
+ ];
+ assert.deepEqual(table.rows(), expected)
+ });
+
+ step.Given(/^a table step with Table rowHash$/, function(table:Table){
+ var expected = {
+ 'Cucumber': 'Cucumis sativus',
+ 'Burr Gherkin': 'Cucumis anguria'
+ };
+ assert.deepEqual(table.rowsHash(), expected)
+ });
+
+ step.Given(/^a table step$/, function(table:Table){
+ var expected = [
+ {'Vegetable': 'Apricot', 'Rating': '5'},
+ {'Vegetable': 'Brocolli', 'Rating': '2'},
+ {'Vegetable': 'Cucumber', 'Rating': '10'}
+ ];
+ assert.deepEqual(table.hashes(), expected)
+ });
}
diff --git a/cucumber/cucumber.d.ts b/cucumber/cucumber.d.ts
index 6c4273e4e0..cb37208477 100644
--- a/cucumber/cucumber.d.ts
+++ b/cucumber/cucumber.d.ts
@@ -10,8 +10,17 @@ declare namespace cucumber {
(errror?:any):void;
}
+ export interface TableDefinition{
+ raw: () => Array;
+ rows: () => Array;
+ rowsHash: () => {};
+ hashes: () => {};
+ }
+
+ type StepDefinitionParam = string | CallbackStepDefinition | TableDefinition;
+
interface StepDefinitionCode {
- (...stepArgs: Array): PromiseLike | any | void;
+ (...stepArgs: Array): PromiseLike | any | void;
}
interface StepDefinitionOptions{