@@ -20,74 +20,89 @@ yesterday.setDate(yesterday.getDate() - 1);
2020let twoDaysAgo = new Date ( ) ;
2121twoDaysAgo . setDate ( twoDaysAgo . getDate ( ) - 2 ) ;
2222
23-
2423describe ( "history container test" , ( ) => {
2524 const initialState = {
26- business : { history : [
27- {
28- date : format ( today , "MM/DD/YYYY" ) ,
29- history : [
30- {
31- id : 1 ,
32- created_at : today ,
33- url : "http://google.com" ,
34- request : {
35- method : "GET" ,
25+ business : {
26+ history : [
27+ {
28+ date : format ( today , "MM/DD/YYYY" ) ,
29+ history : [
30+ {
31+ id : 1 ,
32+ created_at : today ,
33+ url : "http://google.com" ,
34+ request : {
35+ method : "GET" ,
36+ } ,
3637 } ,
37- } ,
38- ] ,
39- } ,
40- {
41- date : format ( yesterday , "MM/DD/YYYY" ) ,
42- history : [
43- {
44- id : 2 ,
45- created_at : yesterday ,
46- url : "http://facebook.com" ,
47- request : {
48- method : "GET" ,
38+ ] ,
39+ } ,
40+ {
41+ date : format ( yesterday , "MM/DD/YYYY" ) ,
42+ history : [
43+ {
44+ id : 2 ,
45+ created_at : yesterday ,
46+ url : "http://facebook.com" ,
47+ request : {
48+ method : "GET" ,
49+ } ,
4950 } ,
50- } ,
51- ] ,
52- } ,
53- {
54- date : format ( twoDaysAgo , "MM/DD/YYYY" ) ,
55- history : [
56- {
57- id : 3 ,
58- created_at : twoDaysAgo ,
59- url : "http://instagram.com" ,
60- request : {
61- method : "GET" ,
51+ ] ,
52+ } ,
53+ {
54+ date : format ( twoDaysAgo , "MM/DD/YYYY" ) ,
55+ history : [
56+ {
57+ id : 3 ,
58+ created_at : twoDaysAgo ,
59+ url : "http://instagram.com" ,
60+ request : {
61+ method : "GET" ,
62+ } ,
6263 } ,
63- } ,
64- ] ,
65- } ,
66- ] ,
67- } }
64+ ] ,
65+ } ,
66+ ] ,
67+ } ,
68+ } ;
6869 const renderWithRedux = (
6970 component ,
7071 { store = createStore ( reducers , initialState ) } = { }
7172 ) => {
72- console . log ( 'store is: ' , store . getState ( ) )
73- console . log ( 'initial state is: ' , initialState )
7473 return {
7574 ...render ( < Provider store = { store } > { component } </ Provider > ) ,
7675 store,
77- }
78- }
76+ } ;
77+ } ;
7978
8079 beforeEach ( ( ) => {
81- renderWithRedux ( < HistoryContainer /> ) ;
80+ renderWithRedux ( < HistoryContainer /> ) ;
8281 screen . debug ( ) ;
8382 } ) ;
84- test ( "renders history from store" , ( ) => {
85- console . log ( screen . queryAllByRole ( "queryDate" ) ) ;
86- expect ( screen . queryAllByRole ( "queryDate" ) . length ) . toBe ( 3 ) ;
83+ test ( "renders all items in history array from store" , ( ) => {
84+ //console.log(screen.queryAllByLabelText("queryDate"));
85+ expect ( screen . queryAllByLabelText ( "queryDate" ) . length ) . toBe ( 3 ) ;
86+ } ) ;
87+ test ( "correctly renders headers in history container" , ( ) => {
88+ //let oldDay = format(twoDaysAgo, "MM/DD/YYYY");
89+ expect ( screen . queryByText ( "Today" ) ) . toBeTruthy ( ) ;
90+ expect ( screen . queryByText ( "Yesterday" ) ) . toBeTruthy ( ) ;
91+ expect (
92+ screen . queryByText ( format ( twoDaysAgo , "ddd, MMM D, YYYY" ) )
93+ ) . toBeTruthy ( ) ;
94+ } ) ;
95+ test ( "correctly renders url for each header in history" , ( ) => {
96+ expect ( screen . queryByText ( "http://google.com" ) ) . toBeTruthy ( ) ;
97+ expect ( screen . queryByText ( "http://facebook.com" ) ) . toBeTruthy ( ) ;
98+ expect ( screen . queryByText ( "http://instagram.com" ) ) . toBeTruthy ( ) ;
8799 } ) ;
88- // test('renders a history header', () => {
89- // expect(screen.queryByRole('queryDate')).toBeInTheDocument();
90- // })
100+ test ( "correctly renders request method for each header in history" , ( ) => {
101+ expect ( screen . queryAllByText ( "GET" ) . length ) . toBe ( 3 ) ;
102+ } ) ;
103+ test ( "clear history button clears history" , ( ) => {
104+
105+ } )
91106} ) ;
92107//test if container renders
93108// test("renders", () => {
@@ -103,4 +118,3 @@ describe("history container test", () => {
103118//buttons work (clear history, etc.)
104119//forms function (accepts input)
105120//state updates appropriately
106-
0 commit comments