@@ -3,12 +3,8 @@ import { expect } from 'chai'
33import FakeTimers , { InstalledClock } from '@sinonjs/fake-timers'
44import { reindent } from 'reindent-template-literals'
55import timeMethods from '../time'
6- import {
7- getBasicUsageSupportCodeLibrary ,
8- getOrderedUsageSupportCodeLibrary ,
9- } from '../../test/fixtures/usage/usage_steps'
6+ import { getUsageSupportCodeLibrary } from '../../test/fixtures/usage_steps'
107import { testFormatter } from '../../test/formatter_helpers'
11- import { UsageOrder } from './helpers'
128
139describe ( 'UsageFormatter' , ( ) => {
1410 let clock : InstalledClock
@@ -37,7 +33,7 @@ describe('UsageFormatter', () => {
3733 describe ( 'unused' , ( ) => {
3834 it ( 'outputs the step definitions as unused' , async ( ) => {
3935 // Arrange
40- const supportCodeLibrary = getBasicUsageSupportCodeLibrary ( clock )
36+ const supportCodeLibrary = getUsageSupportCodeLibrary ( clock )
4137
4238 // Act
4339 const output = await testFormatter ( {
@@ -51,11 +47,11 @@ describe('UsageFormatter', () => {
5147 ┌────────────────┬──────────┬───────────────────┐
5248 │ Pattern / Text │ Duration │ Location │
5349 ├────────────────┼──────────┼───────────────────┤
54- │ abc │ UNUSED │ usage_steps.ts:13 │
50+ │ abc │ UNUSED │ usage_steps.ts:11 │
5551 ├────────────────┼──────────┼───────────────────┤
56- │ /def?/ │ UNUSED │ usage_steps.ts:18 │
52+ │ /def?/ │ UNUSED │ usage_steps.ts:16 │
5753 ├────────────────┼──────────┼───────────────────┤
58- │ ghi │ UNUSED │ usage_steps.ts:27 │
54+ │ ghi │ UNUSED │ usage_steps.ts:25 │
5955 └────────────────┴──────────┴───────────────────┘
6056
6157 ` )
@@ -74,7 +70,7 @@ describe('UsageFormatter', () => {
7470 uri : 'a.feature' ,
7571 } ,
7672 ]
77- const supportCodeLibrary = getBasicUsageSupportCodeLibrary ( clock )
73+ const supportCodeLibrary = getUsageSupportCodeLibrary ( clock )
7874
7975 // Act
8076 const output = await testFormatter ( {
@@ -90,13 +86,13 @@ describe('UsageFormatter', () => {
9086 ┌────────────────┬──────────┬───────────────────┐
9187 │ Pattern / Text │ Duration │ Location │
9288 ├────────────────┼──────────┼───────────────────┤
93- │ abc │ UNUSED │ usage_steps.ts:13 │
89+ │ abc │ UNUSED │ usage_steps.ts:11 │
9490 ├────────────────┼──────────┼───────────────────┤
95- │ /def?/ │ - │ usage_steps.ts:18 │
91+ │ /def?/ │ - │ usage_steps.ts:16 │
9692 │ de │ - │ a.feature:4 │
9793 │ def │ - │ a.feature:3 │
9894 ├────────────────┼──────────┼───────────────────┤
99- │ ghi │ UNUSED │ usage_steps.ts:27 │
95+ │ ghi │ UNUSED │ usage_steps.ts:25 │
10096 └────────────────┴──────────┴───────────────────┘
10197
10298 ` )
@@ -105,15 +101,15 @@ describe('UsageFormatter', () => {
105101 } )
106102
107103 describe ( 'not in dry run' , ( ) => {
108- it ( 'outputs the step definition with durations' , async ( ) => {
104+ it ( 'outputs the step definition without durations' , async ( ) => {
109105 // Arrange
110106 const sources = [
111107 {
112108 data : 'Feature: a\nScenario: b\nWhen def\nThen de' ,
113109 uri : 'a.feature' ,
114110 } ,
115111 ]
116- const supportCodeLibrary = getBasicUsageSupportCodeLibrary ( clock )
112+ const supportCodeLibrary = getUsageSupportCodeLibrary ( clock )
117113
118114 // Act
119115 const output = await testFormatter ( {
@@ -128,91 +124,19 @@ describe('UsageFormatter', () => {
128124 ┌────────────────┬──────────┬───────────────────┐
129125 │ Pattern / Text │ Duration │ Location │
130126 ├────────────────┼──────────┼───────────────────┤
131- │ /def?/ │ 1.50ms │ usage_steps.ts:18 │
127+ │ /def?/ │ 1.50ms │ usage_steps.ts:16 │
132128 │ def │ 2.00ms │ a.feature:3 │
133129 │ de │ 1.00ms │ a.feature:4 │
134130 ├────────────────┼──────────┼───────────────────┤
135- │ abc │ UNUSED │ usage_steps.ts:13 │
131+ │ abc │ UNUSED │ usage_steps.ts:11 │
136132 ├────────────────┼──────────┼───────────────────┤
137- │ ghi │ UNUSED │ usage_steps.ts:27 │
133+ │ ghi │ UNUSED │ usage_steps.ts:25 │
138134 └────────────────┴──────────┴───────────────────┘
139135
140136 ` )
141137 )
142138 } )
143139 } )
144-
145- describe ( 'sorting' , ( ) => {
146- const sources = [
147- {
148- data : 'Feature: a\nScenario: a\nGiven foo\nThen bar' ,
149- uri : 'a.feature' ,
150- } ,
151- {
152- data : 'Feature: b\nScenario: b\nGiven foo\nThen bar' ,
153- uri : 'b.feature' ,
154- } ,
155- ]
156-
157- it ( 'defaults to order by execution time, decreasingly' , async ( ) => {
158- const supportCodeLibrary = getOrderedUsageSupportCodeLibrary ( clock )
159-
160- // Act
161- const output = await testFormatter ( {
162- sources,
163- supportCodeLibrary,
164- type : 'usage' ,
165- } )
166-
167- // Assert
168- expect ( output ) . to . eql (
169- reindent ( `
170- ┌────────────────┬──────────┬─────────────────┐
171- │ Pattern / Text │ Duration │ Location │
172- ├────────────────┼──────────┼─────────────────┤
173- │ foo │ 15.00ms │ foo_steps.ts:10 │
174- │ foo │ 20.00ms │ b.feature:3 │
175- │ foo │ 10.00ms │ a.feature:3 │
176- ├────────────────┼──────────┼─────────────────┤
177- │ bar │ 3.00ms │ bar_steps.ts:10 │
178- │ bar │ 4.00ms │ b.feature:4 │
179- │ bar │ 2.00ms │ a.feature:4 │
180- └────────────────┴──────────┴─────────────────┘
181-
182- ` )
183- )
184- } )
185-
186- it ( 'can optionally order by location' , async ( ) => {
187- const supportCodeLibrary = getOrderedUsageSupportCodeLibrary ( clock )
188-
189- // Act
190- const output = await testFormatter ( {
191- sources,
192- supportCodeLibrary,
193- type : 'usage' ,
194- parsedArgvOptions : { usage : { order : UsageOrder . LOCATION } } ,
195- } )
196-
197- // Assert
198- expect ( output ) . to . eql (
199- reindent ( `
200- ┌────────────────┬──────────┬─────────────────┐
201- │ Pattern / Text │ Duration │ Location │
202- ├────────────────┼──────────┼─────────────────┤
203- │ bar │ 3.00ms │ bar_steps.ts:10 │
204- │ bar │ 2.00ms │ a.feature:4 │
205- │ bar │ 4.00ms │ b.feature:4 │
206- ├────────────────┼──────────┼─────────────────┤
207- │ foo │ 15.00ms │ foo_steps.ts:10 │
208- │ foo │ 10.00ms │ a.feature:3 │
209- │ foo │ 20.00ms │ b.feature:3 │
210- └────────────────┴──────────┴─────────────────┘
211-
212- ` )
213- )
214- } )
215- } )
216140 } )
217141 } )
218142} )
0 commit comments