Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

Commit 0992a72

Browse files
authored
Merge pull request #101 from sd19oracle/svccat-page2-domtests
Added Page 2 Service Category Tests, fixed page 2 mock
2 parents a8937a2 + 297fb0a commit 0992a72

File tree

3 files changed

+63
-87
lines changed

3 files changed

+63
-87
lines changed
Lines changed: 18 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
{
22
"content": [
33
{
4-
"id": 3,
5-
"popularity": 9,
4+
"id": 10,
5+
"popularity": 2,
66
"icon": "img_url",
7-
"serviceCategoryName": "Pets",
8-
"services": [
9-
{
10-
"id": 678,
11-
"serviceName": "Dog Groomers",
12-
"popularity": 10,
13-
"thumbnail": "https://picsum.photos/300/200",
14-
"questions": []
15-
}
16-
]
17-
},
18-
{
19-
"id": 4,
20-
"popularity": 8,
21-
"icon": "img_url",
22-
"serviceCategoryName": "Wellness",
7+
"serviceCategoryName": "Personal",
238
"services": [
249
{
2510
"id": 543,
@@ -31,55 +16,10 @@
3116
]
3217
},
3318
{
34-
"id": 5,
35-
"popularity": 7,
36-
"icon": "img_url",
37-
"serviceCategoryName": "Business",
38-
"services": [
39-
{
40-
"id": 567,
41-
"serviceName": "Makeup Artists",
42-
"popularity": 9,
43-
"thumbnail": "https://picsum.photos/300/200",
44-
"questions": []
45-
}
46-
]
47-
},
48-
{
49-
"id": 6,
50-
"popularity": 6,
51-
"icon": "img_url",
52-
"serviceCategoryName": "Events",
53-
"services": [
54-
{
55-
"id": 234,
56-
"serviceName": "Exterior Painters",
57-
"popularity": 3,
58-
"thumbnail": "https://picsum.photos/300/200",
59-
"questions": []
60-
}
61-
]
62-
},
63-
{
64-
"id": 7,
65-
"popularity": 5,
19+
"id": 11,
20+
"popularity": 1,
6621
"icon": "img_url",
67-
"serviceCategoryName": "Crafts",
68-
"services": [
69-
{
70-
"id": 345,
71-
"serviceName": "Handymen",
72-
"popularity": 5,
73-
"thumbnail": "https://picsum.photos/300/200",
74-
"questions": []
75-
}
76-
]
77-
},
78-
{
79-
"id": 8,
80-
"popularity": 4,
81-
"icon": "img_url",
82-
"serviceCategoryName": "Design and Web",
22+
"serviceCategoryName": "Photography",
8323
"services": [
8424
{
8525
"id": 456,
@@ -91,19 +31,11 @@
9131
]
9232
},
9333
{
94-
"id": 9,
95-
"popularity": 3,
96-
"icon": "img_url",
97-
"serviceCategoryName": "Legal",
98-
"services": [
99-
{
100-
"id": 456,
101-
"serviceName": "Photographers",
102-
"popularity": 7,
103-
"thumbnail": "https://picsum.photos/300/200",
104-
"questions": []
105-
}
106-
]
34+
"id": 15,
35+
"popularity": 300,
36+
"icon": "",
37+
"serviceCategoryName": "Test1",
38+
"services": []
10739
}
10840
],
10941
"pageable": {
@@ -113,22 +45,22 @@
11345
"empty": true
11446
},
11547
"pageSize": 7,
116-
"pageNumber": 0,
117-
"offset": 0,
48+
"pageNumber": 1,
49+
"offset": 7,
11850
"unpaged": false,
11951
"paged": true
12052
},
12153
"totalElements": 10,
122-
"last": false,
54+
"last": true,
12355
"totalPages": 2,
124-
"first": true,
56+
"first": false,
12557
"sort": {
12658
"sorted": false,
12759
"unsorted": true,
12860
"empty": true
12961
},
130-
"numberOfElements": 7,
62+
"numberOfElements": 3,
13163
"size": 7,
132-
"number": 0,
64+
"number": 1,
13365
"empty": false
134-
}
66+
}

src/test/ServiceCategoryDOM.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ test("count buttons of the DOM, should be 7 lines + input line, 2 per line", ()
2929
);
3030
let root = component.root;
3131
expect(root.findAllByType("button").length).toBe((7+1)*2);
32-
})
32+
})
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import "../services/ServiceCategoryService.mock"
2+
import { MemoryRouter } from "react-router-dom";
3+
import svccatmockdataOne from "../data/service-categories-page1.mock"
4+
import React from 'react'
5+
import renderer from 'react-test-renderer'
6+
import ServiceCategoryService from "../services/ServiceCategoryService"
7+
import ServiceCategoryTable from "../components/ServiceCategoryTable"
8+
const serviceCategoryService = ServiceCategoryService.getInstance();
9+
10+
test("render correct # of entries (second page)", () => {
11+
const component = renderer.create(
12+
<MemoryRouter>
13+
<ServiceCategoryTable
14+
serviceCategories={svccatmockdataOne.content}
15+
new_entry={{ serviceCategoryName: "", popularity: "", icon: "", id: -1 }}/>
16+
</MemoryRouter>
17+
);
18+
let root = component.root;
19+
expect(root.findAllByType("tr").length).toBe(3 + 2);
20+
})
21+
22+
test("count buttons of the DOM, should be 7 lines + input line, 2 per line", () => {
23+
const component = renderer.create(
24+
<MemoryRouter>
25+
<ServiceCategoryTable
26+
serviceCategories={svccatmockdataOne.content}
27+
new_entry={{ serviceCategoryName: "", popularity: "", icon: "", id: -1 }}/>
28+
</MemoryRouter>
29+
);
30+
let root = component.root;
31+
expect(root.findAllByType("button").length).toBe((3+1)*2);
32+
})
33+
34+
test("count input text fields of the DOM, should be 2", () => {
35+
const component = renderer.create(
36+
<MemoryRouter>
37+
<ServiceCategoryTable
38+
serviceCategories={svccatmockdataOne.content}
39+
new_entry={{ serviceCategoryName: "", popularity: "", icon: "", id: -1 }}/>
40+
</MemoryRouter>
41+
);
42+
let root = component.root;
43+
expect(root.findAllByType("input").length).toBe(2);
44+
})

0 commit comments

Comments
 (0)