소스 검색

Unit testing

Ananya_Agarwal 1 년 전
부모
커밋
64c749e9a8
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      desktop/core/src/desktop/js/reactComponents/AlertComponent/AlertComponent.test.tsx

+ 15 - 0
desktop/core/src/desktop/js/reactComponents/AlertComponent/AlertComponent.test.tsx

@@ -89,4 +89,19 @@ describe('AlertComponent', () => {
     expect(alertsAfterClosing[0]).toHaveTextContent('Error 1');
     expect(alertsAfterClosing[1]).toHaveTextContent('Error 3');
   });
+
+  test('info alerts should close automatically after 3 seconds', async () => {
+    render(<AlertComponent />);
+    expect(screen.queryAllByRole('alert')).toHaveLength(0);
+    act(() => huePubSub.publish('hue.global.info', { message: 'info' }));
+    expect(screen.queryAllByRole('alert')).toHaveLength(1);
+
+    //It should still be open after 2 seconds
+    jest.advanceTimersByTime(2000);
+    expect(screen.queryAllByRole('alert')).toHaveLength(1);
+
+    //After 3.1 seconds, it should really be closed
+    jest.advanceTimersByTime(1000);
+    expect(screen.queryAllByRole('alert')).toHaveLength(0);
+  });
 });