@@ -57,69 +57,69 @@ describe('Unit testing for Action.tsx', () => {
57
57
} ) ;
58
58
59
59
describe ( 'When a component is shown on the page' , ( ) => {
60
- // test('Action snapshot should be shown as Snapshot: 3.0', () => {
61
- // render(
62
- // <Action {...props} />
63
- // );
64
- // expect(screen.getByPlaceholderText('Snapshot: 3.0')).toBeInTheDocument();
65
- // });
66
-
67
- // test('Two buttons with Time and Current when not at current snapshot', () => {
68
- // props.isCurrIndex = true;
69
- // render(
70
- // <Action {...props} />
71
- // );
72
- // expect(screen.getAllByRole('button')).toHaveLength(2);
73
- // expect(screen.getAllByRole('button')[0]).toHaveTextContent('+00:03.50');
74
- // expect(screen.getAllByRole('button')[1]).toHaveTextContent('Current');
75
- // });
76
-
77
- // test('Action snapshot should be shown as Snapshot: 3.0', () => {
78
- // render(
79
- // <Action {...props} />
80
- // );
81
- // expect(screen.getByPlaceholderText('Snapshot: 3.0')).toBeInTheDocument();
82
- // });
83
-
84
- // test("When there is no duration data", () => {
85
- // props.componentData = undefined;
86
- // render(
87
- // <Action {...props} />
88
- // );
89
- // expect(screen.getAllByRole('button')[0]).toHaveTextContent('NO TIME');
90
- // });
91
-
92
- // test('When actualDuration exceeds 60, time should be formatted correctly', () => {
93
- // props.componentData.actualDuration = 75;
94
- // render(
95
- // <Action {...props} />
96
- // );
97
- // expect(screen.getAllByRole('button')[0]).toHaveTextContent('+01:15.00');
98
- // });
99
-
100
- // test('Using the ArrowUp key on Action snapshot should trigger handleOnKeyDown', () => {
101
- // render(
102
- // <Action {...props} />
103
- // );
104
- // fireEvent.keyDown(screen.getByRole('presentation'), {key: 'ArrowUp', code: 'ArrowUp', charCode: 38});
105
- // expect(props.handleOnkeyDown).toHaveBeenCalled();
106
- // });
107
-
108
- // test('Using the ArrowDown key on Action snapshot should trigger handleOnKeyDown', () => {
109
- // render(
110
- // <Action {...props} />
111
- // );
112
- // fireEvent.keyDown(screen.getByRole('presentation'), {key: 'ArrowDown', code: 'ArrowDown', charCode: 40});
113
- // expect(props.handleOnkeyDown).toHaveBeenCalled();
114
- // });
115
-
116
- // test('Using the Enter key on Action snapshot should trigger handleOnKeyDown', () => {
117
- // render(
118
- // <Action {...props} />
119
- // );
120
- // fireEvent.keyDown(screen.getByRole('presentation'), {key: 'Enter', code: 'Enter', charCode: 13});
121
- // expect(props.handleOnkeyDown).toHaveBeenCalled();
122
- // });
60
+ test ( 'Action snapshot should be shown as Snapshot: 3.0' , ( ) => {
61
+ render (
62
+ < Action { ...props } />
63
+ ) ;
64
+ expect ( screen . getByPlaceholderText ( 'Snapshot: 3.0' ) ) . toBeInTheDocument ( ) ;
65
+ } ) ;
66
+
67
+ test ( 'Two buttons with Time and Current when not at current snapshot' , ( ) => {
68
+ props . isCurrIndex = true ;
69
+ render (
70
+ < Action { ...props } />
71
+ ) ;
72
+ expect ( screen . getAllByRole ( 'button' ) ) . toHaveLength ( 2 ) ;
73
+ expect ( screen . getAllByRole ( 'button' ) [ 0 ] ) . toHaveTextContent ( '+00:03.50' ) ;
74
+ expect ( screen . getAllByRole ( 'button' ) [ 1 ] ) . toHaveTextContent ( 'Current' ) ;
75
+ } ) ;
76
+
77
+ test ( 'Action snapshot should be shown as Snapshot: 3.0' , ( ) => {
78
+ render (
79
+ < Action { ...props } />
80
+ ) ;
81
+ expect ( screen . getByPlaceholderText ( 'Snapshot: 3.0' ) ) . toBeInTheDocument ( ) ;
82
+ } ) ;
83
+
84
+ test ( "When there is no duration data" , ( ) => {
85
+ props . componentData = undefined ;
86
+ render (
87
+ < Action { ...props } />
88
+ ) ;
89
+ expect ( screen . getAllByRole ( 'button' ) [ 0 ] ) . toHaveTextContent ( 'NO TIME' ) ;
90
+ } ) ;
91
+
92
+ test ( 'When actualDuration exceeds 60, time should be formatted correctly' , ( ) => {
93
+ props . componentData . actualDuration = 75 ;
94
+ render (
95
+ < Action { ...props } />
96
+ ) ;
97
+ expect ( screen . getAllByRole ( 'button' ) [ 0 ] ) . toHaveTextContent ( '+01:15.00' ) ;
98
+ } ) ;
99
+
100
+ test ( 'Using the ArrowUp key on Action snapshot should trigger handleOnKeyDown' , ( ) => {
101
+ render (
102
+ < Action { ...props } />
103
+ ) ;
104
+ fireEvent . keyDown ( screen . getByRole ( 'presentation' ) , { key : 'ArrowUp' , code : 'ArrowUp' , charCode : 38 } ) ;
105
+ expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ;
106
+ } ) ;
107
+
108
+ test ( 'Using the ArrowDown key on Action snapshot should trigger handleOnKeyDown' , ( ) => {
109
+ render (
110
+ < Action { ...props } />
111
+ ) ;
112
+ fireEvent . keyDown ( screen . getByRole ( 'presentation' ) , { key : 'ArrowDown' , code : 'ArrowDown' , charCode : 40 } ) ;
113
+ expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ;
114
+ } ) ;
115
+
116
+ test ( 'Using the Enter key on Action snapshot should trigger handleOnKeyDown' , ( ) => {
117
+ render (
118
+ < Action { ...props } />
119
+ ) ;
120
+ fireEvent . keyDown ( screen . getByRole ( 'presentation' ) , { key : 'Enter' , code : 'Enter' , charCode : 13 } ) ;
121
+ expect ( props . handleOnkeyDown ) . toHaveBeenCalled ( ) ;
122
+ } ) ;
123
123
124
124
test ( 'Clicking the snapshot should trigger onClick' , ( ) => {
125
125
render (
0 commit comments