1
- import statement from './index' ;
1
+ import { statement , htmlStatement } from './index' ;
2
2
3
3
import plays from './plays.json' ;
4
4
import invoices from './invoices.json' ;
@@ -136,3 +136,94 @@ describe('Tests of statement() with invalid play type', () => {
136
136
expect ( ( ) => statement ( playUnknown , mockPlays ) ) . toThrow ( Error ) ;
137
137
} ) ;
138
138
} ) ;
139
+
140
+ describe ( 'Tests of htmlStatement() with full set of test data' , ( ) => {
141
+ const sttResult = htmlStatement ( invoices [ 0 ] , plays ) ;
142
+ console . log ( sttResult )
143
+
144
+ test ( 'verify the full output' , ( ) => {
145
+ expect ( sttResult ) . toBeDefined ( ) ;
146
+ expect ( sttResult ) . toMatch ( / S t a t e m e n t f o r B i g C o / ) ;
147
+ expect ( sttResult ) . toMatch ( / < t d > H a m l e t < \/ t d > < t d > 5 5 < \/ t d > < t d > \$ 6 5 0 .0 0 < \/ t d > / ) ;
148
+ expect ( sttResult ) . toMatch ( / < t d > A s Y o u L i k e I t < \/ t d > < t d > 3 5 < \/ t d > < t d > \$ 5 8 0 .0 0 < \/ t d > / ) ;
149
+ expect ( sttResult ) . toMatch ( / < t d > O t h e l l o < \/ t d > < t d > 4 0 < \/ t d > < t d > \$ 5 0 0 .0 0 < \/ t d > / ) ;
150
+ expect ( sttResult ) . toMatch ( / A m o u n t o w e d i s < e m > \$ 1 , 7 3 0 .0 0 < \/ e m > / ) ;
151
+ expect ( sttResult ) . toMatch ( / Y o u e a r n e d < e m > 4 7 < \/ e m > c r e d i t s / ) ;
152
+ } ) ;
153
+ } ) ;
154
+
155
+ describe ( 'Tests of htmlStatement() with only one comedy play' , ( ) => {
156
+ test ( 'verify comedy with 1 audience' , ( ) => {
157
+ const playComedy = {
158
+ "customer" : "BigCo" ,
159
+ "performances" : [
160
+ {
161
+ "playID" : "as-like" ,
162
+ "audience" : 1
163
+ }
164
+ ]
165
+ } ;
166
+
167
+ const sttResult = htmlStatement ( playComedy , plays ) ;
168
+ expect ( sttResult ) . toMatch ( / S t a t e m e n t f o r B i g C o / ) ;
169
+ expect ( sttResult ) . toMatch ( / < t d > A s Y o u L i k e I t < \/ t d > < t d > 1 < \/ t d > < t d > \$ 3 0 3 .0 0 < \/ t d > / ) ;
170
+ expect ( sttResult ) . toMatch ( / A m o u n t o w e d i s < e m > \$ 3 0 3 .0 0 < \/ e m > / ) ;
171
+ expect ( sttResult ) . toMatch ( / Y o u e a r n e d < e m > 0 < \/ e m > c r e d i t s / ) ;
172
+ } ) ;
173
+
174
+ test ( 'verify comedy with 5 audience' , ( ) => {
175
+ const playComedy = {
176
+ "customer" : "BigCo" ,
177
+ "performances" : [
178
+ {
179
+ "playID" : "as-like" ,
180
+ "audience" : 5
181
+ }
182
+ ]
183
+ } ;
184
+
185
+ const sttResult = htmlStatement ( playComedy , plays ) ;
186
+ expect ( sttResult ) . toMatch ( / S t a t e m e n t f o r B i g C o / ) ;
187
+ expect ( sttResult ) . toMatch ( / < t d > A s Y o u L i k e I t < \/ t d > < t d > 5 < \/ t d > < t d > \$ 3 1 5 .0 0 < \/ t d > / ) ;
188
+ expect ( sttResult ) . toMatch ( / A m o u n t o w e d i s < e m > \$ 3 1 5 .0 0 < \/ e m > / ) ;
189
+ expect ( sttResult ) . toMatch ( / Y o u e a r n e d < e m > 1 < \/ e m > c r e d i t s / ) ;
190
+ } ) ;
191
+ } ) ;
192
+
193
+ describe ( 'Tests of htmlStatement() with only one tragedy play' , ( ) => {
194
+ test ( 'verify tragedy with 1 audience' , ( ) => {
195
+ const playTragedy = {
196
+ "customer" : "BigCo" ,
197
+ "performances" : [
198
+ {
199
+ "playID" : "othello" ,
200
+ "audience" : 1
201
+ }
202
+ ]
203
+ } ;
204
+
205
+ const sttResult = htmlStatement ( playTragedy , plays ) ;
206
+ expect ( sttResult ) . toMatch ( / S t a t e m e n t f o r B i g C o / ) ;
207
+ expect ( sttResult ) . toMatch ( / < t d > O t h e l l o < \/ t d > < t d > 1 < \/ t d > < t d > \$ 4 0 0 .0 0 < \/ t d > / ) ;
208
+ expect ( sttResult ) . toMatch ( / A m o u n t o w e d i s < e m > \$ 4 0 0 .0 0 < \/ e m > / ) ;
209
+ expect ( sttResult ) . toMatch ( / Y o u e a r n e d < e m > 0 < \/ e m > c r e d i t s / ) ;
210
+ } ) ;
211
+
212
+ test ( 'verify tragedy with 5 audience' , ( ) => {
213
+ const playTragedy = {
214
+ "customer" : "BigCo" ,
215
+ "performances" : [
216
+ {
217
+ "playID" : "othello" ,
218
+ "audience" : 5
219
+ }
220
+ ]
221
+ } ;
222
+
223
+ const sttResult = htmlStatement ( playTragedy , plays ) ;
224
+ expect ( sttResult ) . toMatch ( / S t a t e m e n t f o r B i g C o / ) ;
225
+ expect ( sttResult ) . toMatch ( / < t d > O t h e l l o < \/ t d > < t d > 5 < \/ t d > < t d > \$ 4 0 0 .0 0 < \/ t d > / ) ;
226
+ expect ( sttResult ) . toMatch ( / A m o u n t o w e d i s < e m > \$ 4 0 0 .0 0 < \/ e m > / ) ;
227
+ expect ( sttResult ) . toMatch ( / Y o u e a r n e d < e m > 0 < \/ e m > c r e d i t s / ) ;
228
+ } ) ;
229
+ } ) ;
0 commit comments