Skip to content

Commit 2545ded

Browse files
committed
history container test working
1 parent 461e868 commit 2545ded

File tree

2 files changed

+67
-53
lines changed

2 files changed

+67
-53
lines changed

__tests__/basicTest.js

Lines changed: 66 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,74 +20,89 @@ yesterday.setDate(yesterday.getDate() - 1);
2020
let twoDaysAgo = new Date();
2121
twoDaysAgo.setDate(twoDaysAgo.getDate() - 2);
2222

23-
2423
describe("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-

src/client/components/display/HistoryDate.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class HistoryDate extends Component {
5050

5151
return (
5252
<div className="historyDate">
53-
<h1 ariaLabel="queryDate">{date}</h1>
53+
<h1 aria-label="queryDate">{date}</h1>
5454
{histArray}
5555
</div>
5656
);

0 commit comments

Comments
 (0)