Skip to content

Commit 34ee60a

Browse files
committed
fix tests
1 parent 8e70636 commit 34ee60a

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

src/tests/App.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import {BrowserRouter as Router} from 'react-router-dom'
33
import App from '../components/App'
4-
import { xhr_setup, tick } from './utils'
4+
import { xhr_setup, tick, STRINGS } from './utils'
55

66
beforeEach(() => {
77
xhr_setup()
@@ -12,7 +12,7 @@ it('shows tutors', async () => {
1212
router_mode: 'history',
1313
api_root: 'https://socket.tutorcruncher.com',
1414
mode: 'grid',
15-
messages: {no_tutors_found: 'xx'},
15+
messages: STRINGS,
1616
event_callback: () => null,
1717
}
1818
const wrapper = enz.mount(<Router><App config={config} public_key={'good'} url_generator={u => u}/></Router>)
@@ -33,7 +33,7 @@ it('with con filter', async () => {
3333
router_mode: 'history',
3434
api_root: 'https://socket.tutorcruncher.com',
3535
mode: 'grid',
36-
messages: {no_tutors_found: 'xx'},
36+
messages: STRINGS,
3737
contractor_filter: {
3838
label: ['foobar'],
3939
label_exclude: ['spam'],

src/tests/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ it('renders grid', async () => {
1313
router_mode: 'hash',
1414
mode: 'grid',
1515
})
16+
// console.log(pretty_html(div.innerHTML))
1617
expect(r.goto).toBeTruthy()
1718
expect(r.config.contractor_filter).toEqual({})
1819
expect(div.querySelectorAll('.tcs-contractors').length).toBe(1)
19-
// console.log(pretty_html(div.innerHTML))
2020
})
2121

2222

src/tests/utils.js

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const RESPONSES = {
99
}),
1010
'GET:https://socket.tutorcruncher.com/good/contractors': () => ({
1111
status: 200,
12-
content: JSON.stringify(
13-
[
12+
content: JSON.stringify({
13+
'results': [
1414
{
1515
'id': 213386,
1616
'url': 'https://socket.tutorcruncher.com/9c79f14df986a1ec693c/contractors/213386',
@@ -35,7 +35,24 @@ const RESPONSES = {
3535
'photo': 'https://socket.tutorcruncher.com/media/9c79f14df986a1ec693c/213385.thumb.jpg',
3636
'distance': null
3737
}
38-
])
38+
]
39+
})
40+
}),
41+
'GET:https://socket.tutorcruncher.com/good/options': () => ({
42+
status: 200,
43+
content: JSON.stringify({
44+
name: 'Demo Branch',
45+
name_display: 'first_name_initial',
46+
show_stars: true,
47+
display_mode: 'list',
48+
router_mode: 'hash',
49+
show_hours_reviewed: true,
50+
show_labels: true,
51+
show_location_search: true,
52+
show_subject_filter: true,
53+
sort_on: 'name',
54+
pagination: 10,
55+
})
3956
})
4057
}
4158

@@ -85,3 +102,30 @@ export function xhr_setup () {
85102
global.xhr_calls = []
86103
global.XMLHttpRequest = MockXMLHttpRequest
87104
}
105+
106+
// taken directly from index.js
107+
export const STRINGS = {
108+
skills_label: 'Skills',
109+
contractor_enquiry: 'Please enter your details below to enquire about tutoring with {contractor_name}.',
110+
enquiry: 'Please enter your details below and we will get in touch with you shortly.',
111+
contractor_enquiry_button: 'Contact {contractor_name}',
112+
contractor_details_button: 'Show Profile',
113+
submit_enquiry: 'Submit Enquiry',
114+
enquiry_submitted_thanks: 'Enquiry submitted, thank you.',
115+
enquiry_modal_submitted_thanks: 'Enquiry submitted, thank you.\n\nYou can now close this window.',
116+
enquiry_button: 'Get in touch',
117+
enquiry_title: 'Enquiry',
118+
grecaptcha_missing: 'This captcha is required',
119+
required: ' (Required)',
120+
subject_filter_placeholder: 'Select a subject...',
121+
subject_filter_summary_single: '{subject}: showing 1 result',
122+
subject_filter_summary_plural: '{subject}: showing {count} results',
123+
location_input_placeholder: 'Enter your address or zip/postal code...',
124+
view_profile: 'View Profile',
125+
review_hours: '({hours} hours)',
126+
previous: 'Previous',
127+
next: 'Next',
128+
no_tutors_found: 'No more tutors found',
129+
no_tutors_found_loc: 'No more tutors found near this location',
130+
distance_away: '{distance}km away',
131+
}

0 commit comments

Comments
 (0)