-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schemas and unit tests for 22-10216 (#964)
* Adding schema and unit tests for form 10216 * updated version * updated schema * added unit test --------- Co-authored-by: wafimohamed <[email protected]>
- Loading branch information
1 parent
a810daf
commit ceebb27
Showing
3 changed files
with
170 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"title": "22-10216 5% EXEMPTION REQUEST FROM 85/15 REPORTING REQUIREMENT GENERAL INFORMATION (22-10216)", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"definitions": { | ||
"date": { | ||
"pattern": "^(\\d{4}|XXXX)-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$", | ||
"type": "string" | ||
} | ||
}, | ||
"properties": { | ||
"institutionDetails": { | ||
"type": "object", | ||
"required": [ | ||
"institutionName", | ||
"facilityCode", | ||
"termStartDate" | ||
], | ||
"properties": { | ||
"institutionName": { | ||
"type": "string" | ||
}, | ||
"facilityCode": { | ||
"type": "string" | ||
}, | ||
"termStartDate": { | ||
"$ref": "#/definitions/date" | ||
} | ||
} | ||
}, | ||
"studentRatioCalcChapter": { | ||
"type": "object", | ||
"required": [ | ||
"beneficiaryStudent", | ||
"numOfStudent", | ||
"dateOfCalculation" | ||
], | ||
"properties": { | ||
"beneficiaryStudent": { | ||
"type": "integer" | ||
}, | ||
"numOfStudent": { | ||
"type": "integer" | ||
}, | ||
"VaBeneficiaryStudentsPercentage": { | ||
"type": "number" | ||
}, | ||
"dateOfCalculation": { | ||
"$ref": "#/definitions/date" | ||
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import _ from 'lodash'; | ||
import definitions from '../../common/definitions'; | ||
|
||
const origDefinitions = _.cloneDeep(definitions); | ||
|
||
const pickedDefinitions = _.pick(origDefinitions, ['date']); | ||
|
||
const schema = { | ||
$schema: 'http://json-schema.org/draft-04/schema#', | ||
title: '22-10216 5% EXEMPTION REQUEST FROM 85/15 REPORTING REQUIREMENT GENERAL INFORMATION (22-10216)', | ||
type: 'object', | ||
additionalProperties: false, | ||
definitions: pickedDefinitions, | ||
properties: { | ||
institutionDetails: { | ||
type: 'object', | ||
required: ['institutionName', 'facilityCode', 'termStartDate'], | ||
properties: { | ||
institutionName: { | ||
type: 'string', | ||
}, | ||
facilityCode: { | ||
type: 'string', | ||
}, | ||
termStartDate: { | ||
$ref: '#/definitions/date', | ||
}, | ||
}, | ||
}, | ||
studentRatioCalcChapter: { | ||
type: 'object', | ||
required: ['beneficiaryStudent', 'numOfStudent', 'dateOfCalculation'], | ||
properties: { | ||
beneficiaryStudent: { | ||
type: 'integer', | ||
}, | ||
numOfStudent: { | ||
type: 'integer', | ||
}, | ||
VaBeneficiaryStudentsPercentage: { | ||
type: 'number', | ||
}, | ||
dateOfCalculation: { | ||
$ref: '#/definitions/date', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
export default schema; |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { expect } from 'chai'; | ||
import { it } from 'mocha'; | ||
import { cloneDeep } from 'lodash'; | ||
import schema from '../../../src/schemas/22-10216/schema'; | ||
import SchemaTestHelper from '../../support/schema-test-helper'; | ||
|
||
const schemaWithoutRequired = cloneDeep(schema); | ||
|
||
const schemaTestHelper = new SchemaTestHelper(schemaWithoutRequired); | ||
|
||
const testData = { | ||
institutionDetails: { | ||
valid: [ | ||
{ | ||
institutionName: 'Test Institution', | ||
facilityCode: '12345678', | ||
termStartDate: '2024-01-01', | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
institutionName: 'Test Institution', | ||
facilityCode: '12345f6g', | ||
termStartDate: '2024-01-01', | ||
}, | ||
], | ||
}, | ||
studentRatioCalcChapter: { | ||
valid: [ | ||
{ | ||
beneficiaryStudent: 1, | ||
numOfStudent: 1, | ||
dateOfCalculation: '2024-01-01', | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
beneficiaryStudent: '1r', | ||
numOfStudent: '1r', | ||
dateOfCalculation: '20230101', | ||
}, | ||
{ | ||
institutionName: 'Institution of Test', | ||
facilityCode: 'IoT 123', | ||
termStartDate: 'start date', | ||
}, | ||
], | ||
}, | ||
}; | ||
describe('10216 schema', () => { | ||
it('should have required fields', () => { | ||
expect(schema.properties.institutionDetails.required).to.deep.equal([ | ||
'institutionName', | ||
'facilityCode', | ||
'termStartDate', | ||
]); | ||
expect(schema.properties.studentRatioCalcChapter.required).to.deep.equal([ | ||
'beneficiaryStudent', | ||
'numOfStudent', | ||
'dateOfCalculation', | ||
]); | ||
schemaTestHelper.testValidAndInvalid('institutionDetails', testData.institutionDetails); | ||
schemaTestHelper.testValidAndInvalid('studentRatioCalcChapter', testData.studentRatioCalcChapter); | ||
}); | ||
}); |