-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
407 additions
and
214,104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 30 additions & 35 deletions
65
packages/dynamics-lib/src/queries/__tests__/permission.queries.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,36 @@ | ||
import { permissionForFullReferenceNumber, permissionForContacts } from '../permission.queries.js' | ||
import { permissionForLicensee, permissionForFullReferenceNumber } from '../permission.queries.js' | ||
|
||
describe('Permission Queries', () => { | ||
describe('permissionForFullReferenceNumber', () => { | ||
it.each([['ABC123'], ['DEF456'], ['GHI789']])( | ||
'builds a filter to run a query for a permission with a full reference number whch is %s', | ||
async referenceNumber => { | ||
const query = permissionForFullReferenceNumber(referenceNumber) | ||
expect(query.toRetrieveRequest()).toEqual({ | ||
collection: 'defra_permissions', | ||
expand: expect.arrayContaining([ | ||
expect.objectContaining({ property: 'defra_ContactId' }), | ||
expect.objectContaining({ property: 'defra_PermitId' }), | ||
expect.objectContaining({ property: 'defra_defra_permission_defra_concessionproof_PermissionId' }) | ||
]), | ||
filter: `defra_name eq '${referenceNumber}' and statecode eq 0`, | ||
select: expect.any(Array) | ||
}) | ||
} | ||
) | ||
describe('permissionForLicensee', () => { | ||
it('builds a filter to run a query for a permission with a given licensee date of birth and postcode', async () => { | ||
const query = permissionForLicensee('ABC123', '2000-01-01', 'AB12 3CD') | ||
expect(query.toRetrieveRequest()).toEqual({ | ||
collection: 'defra_permissions', | ||
expand: expect.arrayContaining([ | ||
expect.objectContaining({ property: 'defra_ContactId' }), | ||
expect.objectContaining({ property: 'defra_PermitId' }), | ||
expect.objectContaining({ property: 'defra_defra_permission_defra_concessionproof_PermissionId' }) | ||
]), | ||
filter: | ||
"endswith(defra_name, 'ABC123') and defra_ContactId/defra_postcode eq 'AB12 3CD' and defra_ContactId/birthdate eq 2000-01-01 and statecode eq 0", | ||
select: expect.any(Array) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('permissionForContacts', () => { | ||
it.each([['AB12 3CD'], ['EF45 6GH'], ['IJ78 9KL']])( | ||
'builds a filter to run a query for a permission with contact id which is %s', | ||
async contactId => { | ||
const query = permissionForContacts([contactId]) | ||
expect(query.toRetrieveRequest()).toEqual({ | ||
collection: 'defra_permissions', | ||
expand: expect.arrayContaining([ | ||
expect.objectContaining({ property: 'defra_ContactId' }), | ||
expect.objectContaining({ property: 'defra_PermitId' }), | ||
expect.objectContaining({ property: 'defra_defra_permission_defra_concessionproof_PermissionId' }) | ||
]), | ||
filter: `(defra_ContactId/contactid eq '${contactId}') and statecode eq 0`, | ||
select: expect.any(Array) | ||
}) | ||
} | ||
) | ||
describe('permissionForFullReferenceNumber', () => { | ||
it('builds a filter to run a query for a permission with a full reference number', async () => { | ||
const query = permissionForFullReferenceNumber('ABC123') | ||
expect(query.toRetrieveRequest()).toEqual({ | ||
collection: 'defra_permissions', | ||
expand: expect.arrayContaining([ | ||
expect.objectContaining({ property: 'defra_ContactId' }), | ||
expect.objectContaining({ property: 'defra_PermitId' }), | ||
expect.objectContaining({ property: 'defra_defra_permission_defra_concessionproof_PermissionId' }) | ||
]), | ||
filter: "defra_name eq 'ABC123' and statecode eq 0", | ||
select: expect.any(Array) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.