1
1
import React from 'react' ;
2
- import RhythmischApp from " ../pages/app" ;
3
- import { RhythmsProvider } from " ../hooks/rhythms" ;
4
- import { render , screen } from " @testing-library/react" ;
5
- import userEvent from " @testing-library/user-event" ;
6
- import " @testing-library/jest-dom/extend-expect" ;
7
- import { ThemeProvider } from " ../hooks/theme" ;
8
- import { setLocalStorageRhythms } from " ../hooks/rhythms/local-storage" ;
2
+ import RhythmischApp from ' ../pages/app' ;
3
+ import { RhythmsProvider } from ' ../hooks/rhythms' ;
4
+ import { render , screen } from ' @testing-library/react' ;
5
+ import userEvent from ' @testing-library/user-event' ;
6
+ import ' @testing-library/jest-dom/extend-expect' ;
7
+ import { ThemeProvider } from ' ../hooks/theme' ;
8
+ import { setLocalStorageRhythms } from ' ../hooks/rhythms/local-storage' ;
9
9
10
10
const getLocalStorageRhythms = ( ) => {
11
11
const localStorageRhythms = JSON . parse (
12
- window . localStorage . getItem ( " app.rhythms" )
12
+ window . localStorage . getItem ( ' app.rhythms' )
13
13
) ;
14
14
return localStorageRhythms ;
15
15
} ;
@@ -18,9 +18,9 @@ let rhythm;
18
18
19
19
beforeEach ( ( ) => {
20
20
rhythm = {
21
- id : " local-storage-rhythm" ,
22
- action : " pass this test" ,
23
- reason : " tests should pass" ,
21
+ id : ' local-storage-rhythm' ,
22
+ action : ' pass this test' ,
23
+ reason : ' tests should pass' ,
24
24
frequency : [ 1 , 1 ] ,
25
25
hits : [ ] ,
26
26
} ;
@@ -36,7 +36,7 @@ beforeEach(() => {
36
36
) ;
37
37
} ) ;
38
38
39
- it ( " can edit an existing rhythm" , ( ) => {
39
+ it ( ' can edit an existing rhythm' , ( ) => {
40
40
let localStorageRhythms = getLocalStorageRhythms ( ) ;
41
41
expect ( localStorageRhythms ) . toHaveLength ( 1 ) ;
42
42
const localStorageRhythm = localStorageRhythms [ 0 ] ;
@@ -49,31 +49,31 @@ it("can edit an existing rhythm", () => {
49
49
const editButton = screen . getByRole ( 'button' , { name : 'Edit' } ) ;
50
50
userEvent . click ( editButton ) ;
51
51
52
- const modal = screen . getByRole ( " dialog" ) ;
52
+ const modal = screen . getByRole ( ' dialog' ) ;
53
53
expect ( modal ) . toBeInTheDocument ( ) ;
54
54
55
- const action = screen . getByLabelText ( " Rhythm action description" ) ;
56
- const numeratorFrequency = screen . getByLabelText ( " Rhythm action count" ) ;
55
+ const action = screen . getByLabelText ( ' Rhythm action description' ) ;
56
+ const numeratorFrequency = screen . getByLabelText ( ' Rhythm action count' ) ;
57
57
const denomenatorFrequency = screen . getByLabelText (
58
- " Rhythm action count time span"
58
+ ' Rhythm action count time span'
59
59
) ;
60
- const reason = screen . getByLabelText ( " Rhythm reason description" ) ;
61
- const submit = screen . getByRole ( " button" , { name : " Update" } ) ;
60
+ const reason = screen . getByLabelText ( ' Rhythm reason description' ) ;
61
+ const submit = screen . getByRole ( ' button' , { name : ' Update' } ) ;
62
62
63
63
userEvent . clear ( action ) ;
64
- userEvent . type ( action , " read every day" ) ;
65
- userEvent . selectOptions ( numeratorFrequency , " thrice" ) ;
66
- userEvent . selectOptions ( denomenatorFrequency , " week" ) ;
64
+ userEvent . type ( action , ' read every day' ) ;
65
+ userEvent . selectOptions ( numeratorFrequency , ' thrice' ) ;
66
+ userEvent . selectOptions ( denomenatorFrequency , ' week' ) ;
67
67
userEvent . clear ( reason ) ;
68
- userEvent . type ( reason , " there is much I would like to learn" ) ;
68
+ userEvent . type ( reason , ' there is much I would like to learn' ) ;
69
69
userEvent . click ( submit ) ;
70
70
71
71
expect ( modal ) . not . toBeInTheDocument ( ) ;
72
72
73
- expect ( screen . getByText ( " Read every day" ) ) . toBeInTheDocument ( ) ;
74
- expect ( screen . getByText ( " thrice every week" ) ) . toBeInTheDocument ( ) ;
73
+ expect ( screen . getByText ( ' Read every day' ) ) . toBeInTheDocument ( ) ;
74
+ expect ( screen . getByText ( ' thrice every week' ) ) . toBeInTheDocument ( ) ;
75
75
expect (
76
- screen . getByText ( " because there is much I would like to learn" )
76
+ screen . getByText ( ' because there is much I would like to learn' )
77
77
) . toBeInTheDocument ( ) ;
78
78
79
79
localStorageRhythms = getLocalStorageRhythms ( ) ;
@@ -82,7 +82,7 @@ it("can edit an existing rhythm", () => {
82
82
expect ( updatedLocalStorageRhythm . id ) . toBe ( rhythm . id ) ;
83
83
expect ( updatedLocalStorageRhythm . action ) . toBe ( 'read every day' ) ;
84
84
expect ( updatedLocalStorageRhythm . reason ) . toBe (
85
- " there is much I would like to learn"
85
+ ' there is much I would like to learn'
86
86
) ;
87
87
expect ( updatedLocalStorageRhythm . frequency ) . toMatchObject ( [ 3 , 7 ] ) ;
88
88
expect ( updatedLocalStorageRhythm . hits ) . toMatchObject ( [ ] ) ;
0 commit comments