@@ -88,6 +88,85 @@ describe("Cucumber.Ast.Feature", function () {
88
88
} ) ;
89
89
} ) ;
90
90
91
+ describe ( 'getScenarioDescriptionByLines()' , function ( ) {
92
+ describe ( 'from a scenario' , function ( ) {
93
+ describe ( 'with a description' , function ( ) {
94
+ beforeEach ( function ( ) {
95
+ var source =
96
+ 'Feature: Foo\n' +
97
+ ' Scenario: Bar\n' +
98
+ ' My scenario description\n' +
99
+ '\n' +
100
+ ' Then b\n' ;
101
+ var gherkinDocument = new Gherkin . Parser ( ) . parse ( source ) ;
102
+ feature = Cucumber . Ast . Feature ( gherkinDocument . feature , [ ] ) ;
103
+ } ) ;
104
+
105
+ it ( 'returns the keyword' , function ( ) {
106
+ var description = feature . getScenarioDescriptionByLines ( [ 2 ] ) ;
107
+ expect ( description . trim ( ) ) . toEqual ( 'My scenario description' ) ;
108
+ } ) ;
109
+ } ) ;
110
+
111
+ describe ( 'without a description' , function ( ) {
112
+ beforeEach ( function ( ) {
113
+ var source =
114
+ 'Feature: Foo\n' +
115
+ ' Scenario: Bar\n' +
116
+ ' Then b\n' ;
117
+ var gherkinDocument = new Gherkin . Parser ( ) . parse ( source ) ;
118
+ feature = Cucumber . Ast . Feature ( gherkinDocument . feature , [ ] ) ;
119
+ } ) ;
120
+
121
+ it ( 'returns the keyword' , function ( ) {
122
+ expect ( feature . getScenarioDescriptionByLines ( [ 2 ] ) ) . toEqual ( undefined ) ;
123
+ } ) ;
124
+ } ) ;
125
+ } ) ;
126
+
127
+ describe ( 'from an example in a scenario outline' , function ( ) {
128
+ describe ( 'with a description' , function ( ) {
129
+ beforeEach ( function ( ) {
130
+ var source =
131
+ 'Feature: Foo\n' +
132
+ ' Scenario Outline: Bar\n' +
133
+ ' My scenario outline description\n' +
134
+ '\n' +
135
+ ' When <what>\n' +
136
+ '\n' +
137
+ ' Examples:\n' +
138
+ ' | what |\n' +
139
+ ' | b |' ;
140
+ var gherkinDocument = new Gherkin . Parser ( ) . parse ( source ) ;
141
+ feature = Cucumber . Ast . Feature ( gherkinDocument . feature , [ ] ) ;
142
+ } ) ;
143
+
144
+ it ( 'returns the keyword' , function ( ) {
145
+ var description = feature . getScenarioDescriptionByLines ( [ 2 ] ) ;
146
+ expect ( description . trim ( ) ) . toEqual ( 'My scenario outline description' ) ;
147
+ } ) ;
148
+ } ) ;
149
+
150
+ describe ( 'without a description' , function ( ) {
151
+ beforeEach ( function ( ) {
152
+ var source =
153
+ 'Feature: Foo\n' +
154
+ ' Scenario Outline: Bar\n' +
155
+ ' When <what>\n' +
156
+ ' Examples:\n' +
157
+ ' | what |\n' +
158
+ ' | b |' ;
159
+ var gherkinDocument = new Gherkin . Parser ( ) . parse ( source ) ;
160
+ feature = Cucumber . Ast . Feature ( gherkinDocument . feature , [ ] ) ;
161
+ } ) ;
162
+
163
+ it ( 'returns the keyword' , function ( ) {
164
+ expect ( feature . getScenarioDescriptionByLines ( [ 2 ] ) ) . toEqual ( undefined ) ;
165
+ } ) ;
166
+ } ) ;
167
+ } ) ;
168
+ } ) ;
169
+
91
170
describe ( "getKeyword()" , function ( ) {
92
171
it ( "returns the keyword of the feature" , function ( ) {
93
172
expect ( feature . getKeyword ( ) ) . toEqual ( 'keyword' ) ;
0 commit comments