Skip to content

Commit 97e7412

Browse files
authored
Merge pull request #858 from jembi/ocrvs-1673-landing-page
Unnecessary log removed and fixed test cases
2 parents 8e13b81 + c7a7c5e commit 97e7412

File tree

2 files changed

+30
-41
lines changed

2 files changed

+30
-41
lines changed

packages/register/src/views/RegistrarHome/RegistrarHome.test.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ describe('RegistrarHome tests', async () => {
325325
).toContain('Sent for updates (5)')
326326
})
327327
it('renders all items returned from graphql query in ready for reivew', async () => {
328+
const TIME_STAMP = '1544188309380'
328329
Date.now = jest.fn(() => 1554055200000)
329330
const graphqlMock = [
330331
{
@@ -353,8 +354,8 @@ describe('RegistrarHome tests', async () => {
353354
registeredLocationId:
354355
'308c35b4-04f8-4664-83f5-9790e790cde1',
355356
duplicates: null,
356-
createdAt: '2018-05-23T14:44:58+02:00',
357-
modifiedAt: '2018-05-23T14:44:58+02:00'
357+
createdAt: TIME_STAMP,
358+
modifiedAt: TIME_STAMP
358359
},
359360
dateOfBirth: '2010-10-10',
360361
childName: [
@@ -381,8 +382,8 @@ describe('RegistrarHome tests', async () => {
381382
duplicates: ['308c35b4-04f8-4664-83f5-9790e790cd33'],
382383
registeredLocationId:
383384
'308c35b4-04f8-4664-83f5-9790e790cde1',
384-
createdAt: '2007-01-01',
385-
modifiedAt: '2007-01-01'
385+
createdAt: TIME_STAMP,
386+
modifiedAt: TIME_STAMP
386387
},
387388
dateOfBirth: null,
388389
childName: null,
@@ -421,19 +422,23 @@ describe('RegistrarHome tests', async () => {
421422
})
422423
testComponent.component.update()
423424
const data = testComponent.component.find(GridTable).prop('content')
425+
const EXPECTED_DATE_OF_APPLICATION = moment(
426+
moment(TIME_STAMP, 'x').format('YYYY-MM-DD HH:mm:ss'),
427+
'YYYY-MM-DD HH:mm:ss'
428+
).fromNow()
424429

425430
expect(data.length).toBe(2)
426431
expect(data[0].id).toBe('e302f7c5-ad87-4117-91c1-35eaf2ea7be8')
427432
expect(data[0].event_time_elapsed).toBe('8 years ago')
428-
expect(data[0].application_time_elapsed).toBe('10 months ago')
433+
expect(data[0].application_time_elapsed).toBe(EXPECTED_DATE_OF_APPLICATION)
429434
expect(data[0].tracking_id).toBe('BW0UTHR')
430435
expect(data[0].event).toBe('Birth')
431436
expect(data[0].actions).toBeDefined()
432437

433438
testComponent.component.unmount()
434439
})
435440
it('renders all items returned from graphql query in rejected tab', async () => {
436-
const TIME_STAMP = '2018-12-07T13:11:49.380Z'
441+
const TIME_STAMP = '1544188309380'
437442
const graphqlMock = [
438443
{
439444
request: {
@@ -525,13 +530,13 @@ describe('RegistrarHome tests', async () => {
525530

526531
// wait for mocked data to load mockedProvider
527532
await new Promise(resolve => {
528-
setTimeout(resolve, 100)
533+
setTimeout(resolve, 200)
529534
})
530535
testComponent.component.update()
531536
const data = testComponent.component.find(GridTable).prop('content')
532537
const EXPECTED_DATE_OF_REJECTION = moment(
533-
TIME_STAMP,
534-
'YYYY-MM-DD'
538+
moment(TIME_STAMP, 'x').format('YYYY-MM-DD HH:mm:ss'),
539+
'YYYY-MM-DD HH:mm:ss'
535540
).fromNow()
536541

537542
expect(data.length).toBe(2)

packages/search/src/elasticsearch/dbhelper.ts

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,27 @@ export const indexComposition = async (
55
compositionIdentifier: string,
66
body: ICompositionBody
77
) => {
8-
try {
9-
const response = await client.index({
10-
index: 'ocrvs',
11-
type: 'compositions',
12-
id: compositionIdentifier,
13-
body
14-
})
8+
const response = await client.index({
9+
index: 'ocrvs',
10+
type: 'compositions',
11+
id: compositionIdentifier,
12+
body
13+
})
1514

16-
return response
17-
} catch (err) {
18-
// tslint:disable-next-line:no-console
19-
console.log(err)
20-
throw err
21-
}
15+
return response
2216
}
2317

2418
export const updateComposition = async (id: string, body: ICompositionBody) => {
25-
try {
26-
const response = await client.update({
27-
index: 'ocrvs',
28-
type: 'compositions',
29-
id,
30-
body: {
31-
doc: body
32-
}
33-
})
19+
const response = await client.update({
20+
index: 'ocrvs',
21+
type: 'compositions',
22+
id,
23+
body: {
24+
doc: body
25+
}
26+
})
3427

35-
return response
36-
} catch (err) {
37-
// tslint:disable-next-line:no-console
38-
console.log(err)
39-
throw err
40-
}
28+
return response
4129
}
4230

4331
export const searchComposition = async (body: ICompositionBody) => {
@@ -51,8 +39,6 @@ export const searchComposition = async (body: ICompositionBody) => {
5139
})
5240
return response
5341
} catch (err) {
54-
// tslint:disable-next-line:no-console
55-
console.log(err)
5642
return null
5743
}
5844
}
@@ -72,8 +58,6 @@ export const searchByCompositionId = async (compositionId: string) => {
7258
})
7359
return response
7460
} catch (err) {
75-
// tslint:disable-next-line:no-console
76-
console.log(err)
7761
return null
7862
}
7963
}

0 commit comments

Comments
 (0)