-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCentileChart.test.tsx
1210 lines (1049 loc) · 44.9 KB
/
CentileChart.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Tests for Centile Chart
This is a test suite which applies only to the centile chart component.
The centile chart component is a complex component, made of several subcomponents that need tests of their own
Tests here therefore are more integration test, rather than unit tests
Bundled in are several fictional children against which to test. These are found in the testParameters folder.
They are also used in storybook:
prematureThreeMonths - a girl born at 30+2, length
prematureTwentyTwoWeeks - - a girl born at 22 weeks | to demonstrate lack of data
PrematureTwentyTwoWeeksHeight - a girl born at 22 weeks
PrematureTwentyTwoWeeksOFC - a girl born at 22 weeks
termToAYearGirlHeight - a girl born term to a year of age
smallChildJustOverTwo - a boy, term, height from birth to 2y
twoWeightMeasurements - a boy weight, term birth and 2 y
twoToEight - a girl, heights
twoToEightWeight - a boy
termToAYearYearsGirlHeight - a girl from term to over a year
termToTwoYearsGirlHeight - a girl from term to over 2 years
termToOverFourYearsGirlHeight - a girl from term to over 4 years
turnerHeightOneYearToEleven - a girl with Turner's from a year to 11 y
Below is a list of tests that are implemented or need implementing
---------
Props
---------
-[ ] Boy chart presented if sex is 'male'
-[ ] Girl chart presented if sex is 'female'
-[ ] UK-WHO chart presented if reference is 'uk-who'
-[ ] Trisomy 21 chart presented if reference is 'trisomy-21'
-[ ] Turner chart presented if reference is 'turner'
-[ ] Height chart presented if measurementMethod is 'height'
-[ ] Weight chart presented if measurementMethod is 'weight'
-[ ] BMI chart presented if measurementMethod is 'bmi'
-[ ] Head circumference chart presented if measurementMethod is 'ofc'
---------
Labels
---------
-[X] Title text renders correctly
-[X] Subtitle text renders correctly
-[X] Version text renders correctly
-[X] Y axis lable text renders correctly - height
-[X] Y axis lable text renders correctly - weight
-[X] Y axis lable text renders correctly - bmi
-[X] Y axis lable text renders correctly - OFC
-[X] X axis lable text renders correctly - premature infant (Gestation weeks)
-[X] X axis lable text renders correctly - premature infant after term (Gestation or postnatal weeks / months (shown as lollipops))
-[X] X axis lable text renders correctly - infant (Age (in years and months (shown as lollipops)))
-[X] X axis lable text renders correctly - child (age in years)
-[X] reference attribution text renders correctly - UK-WHO
-[X] reference attribution text renders correctly - Trisomy 21
-[X] reference attribution text renders correctly - Turner
-[X] early puberty cut off text renders correctly - boys
-[X] early puberty cut off text renders correctly - girls
-[X] late puberty cut off text renders correctly - boys
-[X] late puberty cut off text renders correctly - girls
------------------
Measurement Points
------------------
These are important to ensure data points are not lost when swapping from one reference to another.
Do not include tests for tooltips on mouseover which are collected in events.
-[X] correct number of measurement points render for preterm infant under term
-[X] correct number of measurement points render for preterm infant now over 42 weeks
-[X] correct number of measurement points render for preterm infant now over 2 years
-[X] correct number of measurement points render for preterm infant now over 4 years
-[X] correct number of measurement points render for term infant under 2 y
-[X] correct number of measurement points render for term infant now over 2y
-[X] correct number of measurement points render for term infant now over 4
-[ ] padding is applied to lowest measurement and the chart truncated
-[ ] padding is applied to highest measurement and the chart truncated
---------
Centiles
---------
One each of these needed for every measurement method and every sex
-[X] centile line renders for 0.4th centile
-[X] centile line renders for 2nd centile
-[X] centile line renders for 9th centile
-[X] centile line renders for 25th centile
-[X] centile line renders for 50th centile
-[X] centile line renders for 75th centile
-[X] centile line renders for 91st centile
-[X] centile line renders for 98th centile
-[X] centile line renders for 99.6th centile
-------------
BMI SDS Lines
-------------
-[X] -4.0 SDS line renders for BMI
-[X] -3.0 SDS line renders for BMI
-[X] +3.0 SDS line renders for BMI
-[X] +3.33 SDS line renders for BMI
-[X] +3.67 SDS line renders for BMI
-[X] +4.0 SDS line renders for BMI
---------
Events
---------
*MouseOver*
!measurements!
-[ ] chronological age is correct
-[ ] chronological age renders on hover over chronological data point
-[ ] corrected age does not render on hover over chronological data point
-[ ] corrected age is correct
-[ ] corrected age renders on hover over corrected data point
-[ ] chronological age does not render on hover over corrected data point
-[ ] no tooltip appears on hover over link line between chronological and corrected measurement points
-[ ] SDS render in tooltip if clinicianFocus is true
-[ ] SDS do not render in tooltip if clinicianFocus is false
-[ ] clinician age advice renders in tooltip if clinicianFocus is true
-[ ] lay age advice renders in tooltip if clinicianFocus is false
-[ ] corrected gestational age renders in tooltip if baby is born less than 37 weeks
-[ ] corrected gestational age does not render in tooltip if baby is born less than 37 weeks but is over 42 weeks corrected
-[ ] measurement date follows dd MMM YYYY format
Errors are generated in the API, but tests are needed to ensure they are presented correctly
-[ ] measurement error is reported if baby is <23 weeks for weight at time of measurement
-[ ] measurement error is reported if baby is <25 weeks for length at time of measurement
-[ ] measurement error is reported if baby is <23 weeks for head circumference at time of measurement
-[ ] measurement error is reported if baby is <42 weeks for BMI at time of measurement
-[ ] measurement is plotted at 22 weeks and over for length
-[ ] measurement is plotted at 22 weeks and over for weight
-[ ] measurement is plotted at 22 weeks and over for head circumference
-[ ] measurement is not plotted below 2 weeks and for BMI
-[ ] measurement is not plotted >20 y for height
-[ ] measurement is not plotted >20 y for weight
-[ ] measurement is not plotted >20 y for BMI
-[ ] measurement is not plotted >18 y for head circumference in boys
-[ ] measurement is not plotted >17 y for head circumference in girls
!bone ages!
-[ ] correct bone age renders when supplied
-[ ] correct SDS renders when supplied
-[ ] correct centile renders when supplied
-[ ] correct comment renders when supplied
-[ ] bone age renders with grey link line
-[ ] bone age renders with associated corrected age (chronological age is false)
-[ ] bone age renders with associated chronological age (corrected age is false)
-[ ] bone age renders with associated corrected age (both ages are true)
!growth chart events!
-[ ] correct event text renders when supplied
-[ ] event caret renders when text supplied
!midparental heights!
-[ ] correct midparental height rendered for a girl
-[ ] correct midparental height rendered for a boy
-[ ] upper limit midparental height tooltip data renders
-[ ] lower limit midparental height tooltip data renders
-[ ] median midparental height tooltip data renders
!thresholds!
-[ ] transition from UK-WHO to UK90 tooltip renders at 4 y
-[ ] transition from lying to standing tooltip renders at 2 y height - boys
-[ ] transition from lying to standing tooltip renders at 2 y height - girls
-[ ] notification of term thresholds tooltip renders at 37-42 weeks - boys
-[ ] notification of term thresholds tooltip renders at 37-42 weeks - girls
-[ ] notification of late puberty area threshold - boys
-[ ] notification of late puberty area threshold - girls
!centiles!
One each of these needed for every measurement method and every sex
-[ ] centile label renders for 0.4th centile
-[ ] centile label renders for 2nd centile
-[ ] centile label renders for 9th centile
-[ ] centile label renders for 25th centile
-[ ] centile label renders for 50th centile
-[ ] centile label renders for 75th centile
-[ ] centile label renders for 91st centile
-[ ] centile label renders for 98th centile
-[ ] centile label renders for 99.6th centile
-[ ] -4.0 SDS label renders for BMI
-[ ] -3.0 SDS label renders for BMI
-[ ] +3.0 SDS label renders for BMI
-[ ] +3.33 SDS label renders for BMI
-[ ] +3.67 SDS label renders for BMI
-[ ] +4.0 SDS label renders for BMI
*Corrected/Chronological Ages Toggle Button*
-[X] corrected measurements only rendered when 'corrected' toggle clicked
-[X] chronological measurements only rendered when 'chronological' toggle clicked
-[X] corrected and chronological measurements both rendered when 'both' toggle clicked
*Life Course View Button*
-[ ] Life course view button renders if full life course not visible
-[ ] Life course view button does not render if full life course is visible
-[ ] Life course view button icon toggles on press
-[ ] Life course view toggles on button press
-[ ] Description text appears on hover over button
-[ ] Zoom disabled in life course view
*Paste Button*
-[x] Paste button present if enableExport prop is true
-[x] Paste button absent if enableExport prop is false
-[x] Description text appears on hover over button
-[x] 'copied' text appears and fades on click
-[-] Grey rim animates round button edge on hover over button
-[x] exportChartCallback triggered on click
-[ ] correct SVG of chart present when exportChartCallback triggered on click
*Zoom*
-[x] Zoom function enabled if enableZoom prop is true
-[x] Show description text if on hover over button
-[x] Zoom function disabled if enableZoom prop is false
-[x] Reset zoom button appears if zoom applied
The following tests need considerations and about their implementations
-[ ] Reset zoom button disabled if zoom not applied
-[ ] Reset zoom button enabled if zoom applied
-[ ] Chart domains reset if Reset zoom button pressed
*/
import * as React from "react";
import { fireEvent,getByTestId,queryByTestId,render, screen, waitFor } from "@testing-library/react";
import '@testing-library/jest-dom';
import CentileChart from "./CentileChart";
import { CentileChartProps } from "./CentileChart.types";
import { MidParentalHeightObject } from "../interfaces/MidParentalHeightObject";
import { monochromeStyles } from '../testParameters/styles/monochromeStyles'
import {prematureThreeMonths} from '../testParameters/measurements/prematureThreeMonths';
import { twoToEightWeight } from "../testParameters/measurements/twoToEightWeight";
import { termToAYearGirlHeight } from "../testParameters/measurements/termToAYearGirlHeight";
import { termToTwoYearsGirlHeight } from "../testParameters/measurements/termToTwoYearsGirlHeight";
import { termToOverFourYearsGirlHeight } from "../testParameters/measurements/termToOverFourYearsGirlHeight";
import { turnerHeightOneYearToEleven } from "../testParameters/measurements/turnerHeightOneYearToEleven";
import { prematureTwentyTwoWeeksWeight } from "../testParameters/measurements/prematureTwentyTwoWeeks";
import { prematureGirlOverFourHeight } from "../testParameters/measurements/prematureGirlOverFourHeight";
import { termGirlWithSingleHeightMeasurementAndBoneAgeAndEvent } from "../testParameters/measurements/termGirlWithSingleHeightMeasurementAndBoneAgeAndEvent";
describe("All tests relate to rendering the centile lines in the height centile chart with no data.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: 'uk-who',
title: 'TestChartTitle',
subtitle: 'TestChartSubtitle',
measurementMethod: 'height',
sex: 'male',
childMeasurements: [],
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
enum MeasurementMethods {
'height'= 'height', 'weight'='weight', 'bmi'='bmi', 'ofc'='ofc'
}
const measurementMethods = [MeasurementMethods.height, MeasurementMethods.weight, MeasurementMethods.bmi, MeasurementMethods.ofc];
it("should render 0.4th centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
// expect(screen.queryByTestId("reference-0-centile-0.4-measurement-"+item)).toBeInTheDocument()
expect(screen.queryByTestId("reference-1-centile-0.4-measurement-"+item)).toBeInTheDocument()
expect(screen.queryByTestId("reference-2-centile-0.4-measurement-"+item)).toBeInTheDocument()
expect(screen.queryByTestId("reference-3-centile-0.4-measurement-"+item)).toBeInTheDocument()
})
});
it("should render 2nd centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
expect(screen.queryByTestId("reference-1-centile-2-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.queryByTestId("reference-2-centile-2-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.queryByTestId("reference-3-centile-2-measurement-"+props.measurementMethod)).toBeInTheDocument()
});
});
it("should render 9th centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
expect(screen.getByTestId("reference-1-centile-9-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-2-centile-9-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-3-centile-9-measurement-"+props.measurementMethod)).toBeInTheDocument()
});
});
it("should render 25th centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
expect(screen.getByTestId("reference-1-centile-25-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-2-centile-25-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-3-centile-25-measurement-"+props.measurementMethod)).toBeInTheDocument()
});
});
it("should render 50th centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
expect(screen.getByTestId("reference-1-centile-50-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-2-centile-50-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-3-centile-50-measurement-"+props.measurementMethod)).toBeInTheDocument()
});
});
it("should render 75th centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
expect(screen.getByTestId("reference-1-centile-75-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-2-centile-75-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-3-centile-75-measurement-"+props.measurementMethod)).toBeInTheDocument()
});
});
it("should render 91st centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
expect(screen.getByTestId("reference-1-centile-91-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-2-centile-91-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-3-centile-91-measurement-"+props.measurementMethod)).toBeInTheDocument()
});
});
it("should render 98th centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
expect(screen.getByTestId("reference-1-centile-98-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-2-centile-98-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-3-centile-98-measurement-"+props.measurementMethod)).toBeInTheDocument()
});
});
it("should render 99.6th centile", () => {
measurementMethods.forEach((item, index) =>{
props.measurementMethod = item
const chart = <CentileChart {...props} />
render(chart);
expect(screen.getByTestId("reference-1-centile-99.6-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-2-centile-99.6-measurement-"+props.measurementMethod)).toBeInTheDocument()
expect(screen.getByTestId("reference-3-centile-99.6-measurement-"+props.measurementMethod)).toBeInTheDocument()
});
});
});
describe("All tests relate to rendering the SDS lines in the BMI centile chart with no data.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: 'uk-who',
title: 'TestChartTitle',
subtitle: 'TestChartSubtitle',
measurementMethod: 'bmi',
sex: 'male',
childMeasurements: [],
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
const sdsLines = [-5,-4, 3, 3.33, 3.67, 4]
sdsLines.forEach((sdsLine, index)=>{
it("should render the "+sdsLine+" line",()=>{
const chart = <CentileChart {...props} />
render(chart);
expect(screen.queryByTestId("reference-1-centile-"+sdsLine+"-bmisds")).toBeInTheDocument()
expect(screen.queryByTestId("reference-2-centile-"+sdsLine+"-bmisds")).toBeInTheDocument()
expect(screen.queryByTestId("reference-3-centile-"+sdsLine+"-bmisds")).toBeInTheDocument()
});
});
});
describe("All tests relate to rendering the text in the height centile chart for an older boy.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: 'uk-who',
title: 'TestChartTitle',
subtitle: 'TestChartSubtitle',
measurementMethod: 'height',
sex: 'male',
childMeasurements: [],
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should render title text correctly", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("TestChartTitle")).toBeInTheDocument()
});
it("should render subtitle text correctly", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("TestChartSubtitle")).toBeInTheDocument()
});
it("should render version text correctly", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("7.0.0")).toBeInTheDocument()
});
it("should render height y axis label text correctly.", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("Height / Length (cm)")).toBeInTheDocument()
});
it("should render weight y axis label text correctly.", () => {
props.measurementMethod="weight"
render(<CentileChart {...props} />);
expect(screen.queryByText("Weight (kg)")).toBeInTheDocument()
});
it("should render bmi y axis label text correctly.", () => {
props.measurementMethod="bmi"
render(<CentileChart {...props} />);
expect(screen.queryByText("Body Mass Index (kg/m²)")).toBeInTheDocument()
});
it("should render head circumference y axis label text correctly.", () => {
props.measurementMethod="ofc"
render(<CentileChart {...props} />);
expect(screen.queryByText("Head Circumference (cm)")).toBeInTheDocument()
});
it("should render age x axis label text correctly.", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("Age (in years)")).toBeInTheDocument()
});
it("should render UK-WHO reference attribution label text correctly.", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("WHO Child Growth Standards, UK 1990 reference data, reanalysed 2009")).toBeInTheDocument()
});
it("should render Trisomy 21 reference attribution label text correctly.", () => {
props.reference="trisomy-21"
render(<CentileChart {...props} />);
expect(screen.queryByText("Styles ME, Cole TJ, Dennis J, Preece MA. New cross sectional stature, weight and head circumference references for Down’s syndrome in the UK and Republic of Ireland. Arch Dis Child 2002;87:104-8. BMI centiles added 11/11/2013")).toBeInTheDocument()
});
it("should render early puberty cut off text in a boy.", () => {
render(<CentileChart {...props} />);
expect(screen.getAllByText("Puberty starting before 9 years is precocious.")[0]).toBeInTheDocument()
});
it("should render delayed puberty cut off text in a boy.", () => {
render(<CentileChart {...props} />);
expect(screen.getAllByText("Puberty is delayed if no signs are present by 14y.")[0]).toBeInTheDocument()
});
it("should render late puberty cut off text in a boy.", () => {
render(<CentileChart {...props} />);
expect(screen.getAllByText("Puberty completing after 17y is delayed.")[0]).toBeInTheDocument()
});
});
describe("All tests relate to rendering the text in the height centile chart for an older girl.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "ChartVersion",
reference: 'uk-who',
title: 'TestChartTitle',
subtitle: 'TestChartSubtitle',
measurementMethod: 'height',
sex: 'female',
childMeasurements: [],
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false
};
});
it("should render early puberty cut off text in a girl.", () => {
render(<CentileChart {...props} />);
expect(screen.getAllByText("Puberty starting before 8 years is precocious.")[0]).toBeInTheDocument()
});
it("should render delayed puberty cut off text in a girl.", () => {
render(<CentileChart {...props} />);
expect(screen.getAllByText("Puberty is delayed if no signs are present by 13y.")[0]).toBeInTheDocument()
});
it("should render late puberty cut off text in a girl.", () => {
render(<CentileChart {...props} />);
expect(screen.getAllByText("Puberty completing after 16y is delayed.")[0]).toBeInTheDocument()
});
it("should render Turner reference attribution label text correctly.", () => {
props.reference="turner"
props.sex="female"
render(<CentileChart {...props} />);
expect(screen.queryByText("UK Turner reference data, 1985. Lyon, Preece and Grant (1985).")).toBeInTheDocument()
});
// it("centile labels should render.", () => {
// render(<CentileChart {...props} />);
// expect(screen.getAllByText("99.6th")[0]).toBeInTheDocument()
// });
// it("centile labels should not render.", () => {
// props.showCentileLabels=false;
// render(<CentileChart {...props} />);
// expect(screen.queryAllByText("99.6th")[0]).toBeUndefined();
// });
});
describe("All tests relate to rendering the text in the height/length centile chart for a premature neonate.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "ChartVersion",
reference: 'uk-who',
title: 'TestChartTitle',
subtitle: 'TestChartSubtitle',
measurementMethod: 'height',
sex: 'female',
childMeasurements: prematureThreeMonths,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should render title text correctly", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("TestChartTitle")).toBeInTheDocument()
});
it("should render subtitle text correctly", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("TestChartSubtitle")).toBeInTheDocument()
});
it("should render height y axis label text correctly.", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("Height / Length (cm)")).toBeInTheDocument()
});
it("should render age x axis label text correctly for premature infant.", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("Gestation or postnatal weeks / months (shown as lollipops)")).toBeInTheDocument()
});
});
describe("All tests relate to plotting in the height/length centile chart for a premature neonate.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "ChartVersion",
reference: 'uk-who',
title: 'TestChartTitle',
subtitle: 'TestChartSubtitle',
measurementMethod: 'height',
sex: 'female',
childMeasurements: prematureThreeMonths,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should plot 23 x points for corrected age.", () => {
render(<CentileChart {...props} />);
expect(screen.getAllByTestId('correctedMeasurementXPoint')).toHaveLength(23);
});
it("should not render point for corrected age.", () => {
render(<CentileChart {...props} />);
expect(screen.queryAllByTestId('chronologicalMeasurementPoint')).toHaveLength(0);
});
it("should plot 23 chronological points on click of `chronological` toggle.", () => {
render(<CentileChart {...props} />);
fireEvent.click(screen.getByTestId('unadjusted'));
expect(screen.queryAllByTestId('chronologicalMeasurementPoint')).toHaveLength(23);
});
it("should plot 23 chronological points and 23 corrected x points on click of `both` toggle.", () => {
const chart = render(<CentileChart {...props} />);
fireEvent.click(screen.getByTestId('both'));
expect(chart.queryAllByTestId('chronologicalMeasurementPoint')).toHaveLength(23);
expect(chart.queryAllByTestId('correctedMeasurementXPoint')).toHaveLength(23);
});
});
describe("All tests relating to rendering the text in the weight centile chart for an older boy.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "ChartVersion",
reference: "uk-who",
title: "TestChartTitle",
subtitle: "TestChartSubtitle",
measurementMethod: "weight",
sex: 'male',
childMeasurements: twoToEightWeight,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should render title text correctly", () => {
render(<CentileChart{...props} />);
expect(screen.queryByText("TestChartTitle")).toBeInTheDocument()
});
it("should render subtitle text correctly", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("TestChartSubtitle")).toBeInTheDocument()
});
it("should render weight y axis label text correctly", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("Weight (kg)")).toBeInTheDocument();
});
it("should render age x axis label correctly", () => {
render(<CentileChart {...props} />);
expect(screen.queryByText("Age (in years)"))
});
});
describe("All test relating to plotting in the weight centile chart for a toddler between two and eight years.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "ChartVersion",
reference: "uk-who",
title: "TestChartTitle",
subtitle: "TestChartSubtitle",
measurementMethod: "weight",
sex: 'male',
childMeasurements: twoToEightWeight,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should plot 73 x points for chronological age", () => {
render(<CentileChart {...props} />);
expect(screen.getAllByTestId('chronologicalMeasurementPoint')).toHaveLength(73);
});
});
describe("All tests relating to plotting in the height centile chart for a premature girl to three months of age.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: "uk-who",
title: "TestChartTitle",
subtitle: "TestChartSubtitle",
measurementMethod: "height",
sex: 'female',
childMeasurements: prematureThreeMonths,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should plot x axis correctly in the first year of life.", () => {
render(<CentileChart {...props} />);
expect(screen.getByText('Gestation or postnatal weeks / months (shown as lollipops)')).toBeInTheDocument();
});
});
describe("All tests relating to plotting height centile chart for a girl with Turner.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: "turner",
title: "TestChartTitle",
subtitle: "TestChartSubtitle",
measurementMethod: "height",
sex: 'female',
childMeasurements: turnerHeightOneYearToEleven,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should plot turner reference text correctly.", () => {
render(<CentileChart {...props} />);
expect(screen.getByText('UK Turner reference data, 1985. Lyon, Preece and Grant (1985).')).toBeInTheDocument();
});
});
describe("All tests relating to plotting weight centile chart for an extremely preterm girl not yet term.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: "uk-who",
title: "TestChartTitle",
subtitle: "TestChartSubtitle",
measurementMethod: "weight",
sex: 'female',
childMeasurements: prematureTwentyTwoWeeksWeight,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should plot x axis correctly in the first year of life.", () => {
render(<CentileChart {...props} />);
expect(screen.getByText('Gestation (weeks)')).toBeInTheDocument();
});
it("should plot 16 x points for corrected age.", () => {
render(<CentileChart {...props} />);
fireEvent.click(screen.getByTestId('adjusted'));
expect(screen.getAllByTestId('correctedMeasurementXPoint')).toHaveLength(16);
});
it("should plot 16 x points for chronological age.", () => {
render(<CentileChart {...props} />);
fireEvent.click(screen.getByTestId('unadjusted'));
expect(screen.queryAllByTestId('chronologicalMeasurementPoint')).toHaveLength(16);
});
});
describe("All tests relating to plotting weight centile chart for an extremely preterm girl now over 4y.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: "uk-who",
title: "Premature Girl",
subtitle: "Now over 4y",
measurementMethod: "height",
sex: 'female',
childMeasurements: prematureGirlOverFourHeight,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should plot 16 x points for corrected age.", () => {
render(<CentileChart {...props} />);
fireEvent.click(screen.getByTestId('adjusted'));
expect(screen.getAllByTestId('correctedMeasurementXPoint')).toHaveLength(14);
});
it("should plot 16 x points for chronological age.", () => {
render(<CentileChart {...props} />);
fireEvent.click(screen.getByTestId('unadjusted'));
expect(screen.queryAllByTestId('chronologicalMeasurementPoint')).toHaveLength(14);
});
});
describe("All tests relating to plotting height centile chart for a term girl until a year.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: "uk-who",
title: "Term Girl",
subtitle: "Now a year",
measurementMethod: "height",
sex: 'female',
childMeasurements: termToAYearGirlHeight,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false
};
});
it("should plot 85 x points for chronological age.", () => {
render(<CentileChart {...props} />);
expect(screen.queryAllByTestId('chronologicalMeasurementPoint')).toHaveLength(85);
});
it("should plot 0 x points for corrected age.", () => {
render(<CentileChart {...props} />);
expect(screen.queryAllByTestId('correctedMeasurementPoint')).toHaveLength(0);
});
});
describe("All tests relating to plotting height centile chart for a term girl until over two years.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: "uk-who",
title: "Term Girl",
subtitle: "Now over 2 years",
measurementMethod: "height",
sex: 'female',
childMeasurements: termToTwoYearsGirlHeight,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should plot 7 x points for chronological age.", () => {
render(<CentileChart {...props} />);
expect(screen.queryAllByTestId('chronologicalMeasurementPoint')).toHaveLength(7);
});
it("should plot 0 x points for corrected age.", () => {
render(<CentileChart {...props} />);
expect(screen.queryAllByTestId('correctedMeasurementPoint')).toHaveLength(0);
});
});
describe("All tests relating to plotting height centile chart for a term girl until over four years.", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: "uk-who",
title: "Term Girl",
subtitle: "Now over 4 years",
measurementMethod: "height",
sex: 'female',
childMeasurements: termToOverFourYearsGirlHeight,
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false,
};
});
it("should plot 14 dot points for chronological age.", () => {
render(<CentileChart {...props} />);
expect(screen.queryAllByTestId('chronologicalMeasurementPoint')).toHaveLength(14);
});
it("should plot 0 x points for corrected age.", () => {
render(<CentileChart {...props} />);
expect(screen.queryAllByTestId('correctedMeasurementPoint')).toHaveLength(0);
});
});
// Paste button tests
describe("All tests relating to testing the copy button", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}
beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: 'uk-who',
title: 'TestChartTitle',
subtitle: 'TestChartSubtitle',
measurementMethod: 'height',
sex: 'male',
childMeasurements: [],
midParentalHeightData: midparentalHeight,
enableZoom: false,
styles: monochromeStyles,
enableExport: true,
exportChartCallback: ()=>null,
clinicianFocus: false
};
});
it("should show that paste button is present if enableExport prop is true", () => {
render(<CentileChart {...props} />);
expect(screen.queryByTestId("copy-button")).toBeInTheDocument();
})
it("should show the Copy Graph text upon hovering", () => {
render(<CentileChart {...props} />);
fireEvent.mouseEnter(screen.getByTestId('copy-button'));
expect(screen.queryByText("Copy Graph"));
})
it("should show the 'copied' text upon clicking and then it should fade", async () => {
render(<CentileChart {...props} />);
fireEvent.click(screen.getByTestId('copy-button'));