1
- import { makeArrayOfObjects , buildOptionsObj } from '../src/components/helper/processLogHelper.js' ;
1
+ /**
2
+ * @jest -environment jsdom
3
+ */
4
+
5
+ import { makeArrayOfObjects , buildOptionsObj } from '../src/components/helper/processLogHelper.js' ;
2
6
import React from 'react' ;
3
7
4
8
describe ( 'makeArrayOfObjects' , ( ) => {
@@ -57,4 +61,54 @@ describe('makeArrayOfObjects', () => {
57
61
expect ( result [ 0 ] . timeStamp ) . toEqual ( '' ) ;
58
62
expect ( result [ 0 ] . logMsg ) . toEqual ( '' ) ;
59
63
} ) ;
60
- } ) ;
64
+ } ) ;
65
+
66
+ describe ( 'buildOptionsObj' , ( ) => {
67
+
68
+ let sinceButton ;
69
+ let tailButton ;
70
+ let sinceInput ;
71
+ let tailInput ;
72
+
73
+ beforeEach ( ( ) => {
74
+ sinceButton = document . createElement ( 'input' ) ;
75
+ sinceButton . setAttribute ( 'type' , 'radio' ) ;
76
+ sinceButton . setAttribute ( 'id' , 'sinceInput' ) ;
77
+ document . body . appendChild ( sinceButton ) ;
78
+
79
+ tailButton = document . createElement ( 'input' ) ;
80
+ tailButton . setAttribute ( 'id' , 'tailInput' ) ;
81
+ tailButton . setAttribute ( 'type' , 'radio' ) ;
82
+ document . body . appendChild ( tailButton ) ;
83
+
84
+ sinceInput = document . createElement ( 'input' ) ;
85
+ sinceInput . setAttribute ( 'id' , 'sinceText' ) ;
86
+ sinceInput . setAttribute ( 'value' , '72h10m3s' ) ;
87
+ document . body . appendChild ( sinceInput ) ;
88
+
89
+ tailInput = document . createElement ( 'input' ) ;
90
+ tailInput . setAttribute ( 'id' , 'tailText' ) ;
91
+ tailInput . setAttribute ( 'value' , '1' ) ;
92
+ document . body . appendChild ( tailInput ) ;
93
+ } ) ;
94
+
95
+ afterEach ( ( ) => {
96
+ document . body . innerHTML = '' ;
97
+ } ) ;
98
+
99
+ it ( 'when tail button is checked, tail value is added to optionsObj' , ( ) => {
100
+ tailButton . checked = true ;
101
+
102
+ const result = buildOptionsObj ( 'containerID' ) ;
103
+
104
+ expect ( result . tail ) . toEqual ( '1' ) ;
105
+ } ) ;
106
+
107
+ it ( 'when since button is checked, since value is added to since key on optionsObj' , ( ) => {
108
+ sinceButton . checked = true ;
109
+
110
+ const result = buildOptionsObj ( 'containerID' ) ;
111
+
112
+ expect ( result . since ) . toEqual ( '72h10m3s' ) ;
113
+ } ) ;
114
+ } ) ;
0 commit comments