Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddentao committed Jan 25, 2019
1 parent cc8ac3b commit 8942a42
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/legal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const assertHasAcceptedLegalAgreements = legal => {
}
}

export const getLegalAgreement = (legal, idType) => {
return (legal || []).find(({ type }) => type === idType) || null
}
export const getLegalAgreement = (legal, idType) => (
(legal || []).find(({ type }) => type === idType) || null
)

export const getUserAcceptedLegalAgreement = (userLegal, actualLegal, idType) => {
const actual = actualLegal.find(({ type }) => type === idType)
Expand Down
23 changes: 19 additions & 4 deletions src/legal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,25 @@ describe('legal agreements', () => {
expect(getLegalAgreement(legal2, LEGAL.PRIVACY_POLICY)).toEqual({ type: 'PRIVACY_POLICY', id: 'id2' })
expect(getLegalAgreement(legal2, LEGAL.MARKETING_INFO)).toEqual(null)

const actualLegal = [ { type: 'TERMS_AND_CONDITIONS', id: 'id1' }, { type: 'PRIVACY_POLICY', id: 'id2', accepted: true }, { type: 'MARKETING', id: 'id3' } ]
const userLegal = [ { type: 'TERMS_AND_CONDITIONS', accepted: true, id: 'id1' }, { type: 'PRIVACY_POLICY', id: 'id4', accepted: true }, { type: 'MARKETING' } ]
const actualLegal = [
{ type: 'TERMS_AND_CONDITIONS', id: 'id1' },
{ type: 'PRIVACY_POLICY', id: 'id2', accepted: true },
{ type: 'MARKETING', id: 'id3' }
]
const userLegal = [
{ type: 'TERMS_AND_CONDITIONS', accepted: true, id: 'id1' },
{ type: 'PRIVACY_POLICY', id: 'id4', accepted: true },
{ type: 'MARKETING' }
]

const l = getUserAcceptedLegalAgreement(userLegal, actualLegal, LEGAL.TERMS_AND_CONDITIONS)
expect(l).toEqual({
type: 'TERMS_AND_CONDITIONS',
accepted: true,
id: 'id1'
})

expect(getUserAcceptedLegalAgreement(userLegal, actualLegal, LEGAL.TERMS_AND_CONDITIONS)).toEqual({ type: 'TERMS_AND_CONDITIONS', accepted: true, id: 'id1' })
expect(getUserAcceptedLegalAgreement(userLegal, actualLegal, LEGAL.PRIVACY_POLICY)).toEqual(null)
const l2 = getUserAcceptedLegalAgreement(userLegal, actualLegal, LEGAL.PRIVACY_POLICY)
expect(l2).toEqual(null)
})
})

0 comments on commit 8942a42

Please sign in to comment.