Skip to content

Commit

Permalink
Merge pull request #858 from jembi/ocrvs-1673-landing-page
Browse files Browse the repository at this point in the history
Unnecessary log removed and fixed test cases
  • Loading branch information
euanmillar authored Jun 17, 2019
2 parents 8e13b81 + c7a7c5e commit 97e7412
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 41 deletions.
23 changes: 14 additions & 9 deletions packages/register/src/views/RegistrarHome/RegistrarHome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ describe('RegistrarHome tests', async () => {
).toContain('Sent for updates (5)')
})
it('renders all items returned from graphql query in ready for reivew', async () => {
const TIME_STAMP = '1544188309380'
Date.now = jest.fn(() => 1554055200000)
const graphqlMock = [
{
Expand Down Expand Up @@ -353,8 +354,8 @@ describe('RegistrarHome tests', async () => {
registeredLocationId:
'308c35b4-04f8-4664-83f5-9790e790cde1',
duplicates: null,
createdAt: '2018-05-23T14:44:58+02:00',
modifiedAt: '2018-05-23T14:44:58+02:00'
createdAt: TIME_STAMP,
modifiedAt: TIME_STAMP
},
dateOfBirth: '2010-10-10',
childName: [
Expand All @@ -381,8 +382,8 @@ describe('RegistrarHome tests', async () => {
duplicates: ['308c35b4-04f8-4664-83f5-9790e790cd33'],
registeredLocationId:
'308c35b4-04f8-4664-83f5-9790e790cde1',
createdAt: '2007-01-01',
modifiedAt: '2007-01-01'
createdAt: TIME_STAMP,
modifiedAt: TIME_STAMP
},
dateOfBirth: null,
childName: null,
Expand Down Expand Up @@ -421,19 +422,23 @@ describe('RegistrarHome tests', async () => {
})
testComponent.component.update()
const data = testComponent.component.find(GridTable).prop('content')
const EXPECTED_DATE_OF_APPLICATION = moment(
moment(TIME_STAMP, 'x').format('YYYY-MM-DD HH:mm:ss'),
'YYYY-MM-DD HH:mm:ss'
).fromNow()

expect(data.length).toBe(2)
expect(data[0].id).toBe('e302f7c5-ad87-4117-91c1-35eaf2ea7be8')
expect(data[0].event_time_elapsed).toBe('8 years ago')
expect(data[0].application_time_elapsed).toBe('10 months ago')
expect(data[0].application_time_elapsed).toBe(EXPECTED_DATE_OF_APPLICATION)
expect(data[0].tracking_id).toBe('BW0UTHR')
expect(data[0].event).toBe('Birth')
expect(data[0].actions).toBeDefined()

testComponent.component.unmount()
})
it('renders all items returned from graphql query in rejected tab', async () => {
const TIME_STAMP = '2018-12-07T13:11:49.380Z'
const TIME_STAMP = '1544188309380'
const graphqlMock = [
{
request: {
Expand Down Expand Up @@ -525,13 +530,13 @@ describe('RegistrarHome tests', async () => {

// wait for mocked data to load mockedProvider
await new Promise(resolve => {
setTimeout(resolve, 100)
setTimeout(resolve, 200)
})
testComponent.component.update()
const data = testComponent.component.find(GridTable).prop('content')
const EXPECTED_DATE_OF_REJECTION = moment(
TIME_STAMP,
'YYYY-MM-DD'
moment(TIME_STAMP, 'x').format('YYYY-MM-DD HH:mm:ss'),
'YYYY-MM-DD HH:mm:ss'
).fromNow()

expect(data.length).toBe(2)
Expand Down
48 changes: 16 additions & 32 deletions packages/search/src/elasticsearch/dbhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,27 @@ export const indexComposition = async (
compositionIdentifier: string,
body: ICompositionBody
) => {
try {
const response = await client.index({
index: 'ocrvs',
type: 'compositions',
id: compositionIdentifier,
body
})
const response = await client.index({
index: 'ocrvs',
type: 'compositions',
id: compositionIdentifier,
body
})

return response
} catch (err) {
// tslint:disable-next-line:no-console
console.log(err)
throw err
}
return response
}

export const updateComposition = async (id: string, body: ICompositionBody) => {
try {
const response = await client.update({
index: 'ocrvs',
type: 'compositions',
id,
body: {
doc: body
}
})
const response = await client.update({
index: 'ocrvs',
type: 'compositions',
id,
body: {
doc: body
}
})

return response
} catch (err) {
// tslint:disable-next-line:no-console
console.log(err)
throw err
}
return response
}

export const searchComposition = async (body: ICompositionBody) => {
Expand All @@ -51,8 +39,6 @@ export const searchComposition = async (body: ICompositionBody) => {
})
return response
} catch (err) {
// tslint:disable-next-line:no-console
console.log(err)
return null
}
}
Expand All @@ -72,8 +58,6 @@ export const searchByCompositionId = async (compositionId: string) => {
})
return response
} catch (err) {
// tslint:disable-next-line:no-console
console.log(err)
return null
}
}

0 comments on commit 97e7412

Please sign in to comment.