-
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.
22-10215 schema added for 'Institution details' page
- Loading branch information
1 parent
1cc39d1
commit 42fdbc3
Showing
4 changed files
with
116 additions
and
1 deletion.
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,37 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"title": "22-10215 Statement of Assurance of Compliance with 95 Percent Enrollment Ratios (22-10215)", | ||
"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", | ||
"dateOfCalculations" | ||
], | ||
"properties": { | ||
"institutionName": { | ||
"type": "string" | ||
}, | ||
"facilityCode": { | ||
"type": "string" | ||
}, | ||
"termStartDate": { | ||
"$ref": "#/definitions/date" | ||
}, | ||
"dateOfCalculations": { | ||
"$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
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,36 @@ | ||
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-10215 Statement of Assurance of Compliance with 95 Percent Enrollment Ratios (22-10215)', | ||
type: 'object', | ||
additionalProperties: false, | ||
definitions: pickedDefinitions, | ||
properties: { | ||
institutionDetails: { | ||
type: 'object', | ||
required: ['institutionName', 'facilityCode', 'termStartDate', 'dateOfCalculations'], | ||
properties: { | ||
institutionName: { | ||
type: 'string', | ||
}, | ||
facilityCode: { | ||
type: 'string', | ||
}, | ||
termStartDate: { | ||
$ref: '#/definitions/date', | ||
}, | ||
dateOfCalculations: { | ||
$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,42 @@ | ||
import { expect } from 'chai'; | ||
import { it } from 'mocha'; | ||
import { cloneDeep } from 'lodash'; | ||
import schema from '../../../src/schemas/22-10215/schema'; | ||
import SchemaTestHelper from '../../support/schema-test-helper'; | ||
|
||
const schemaWithoutRequired = cloneDeep(schema); | ||
delete schemaWithoutRequired.required; | ||
|
||
const schemaTestHelper = new SchemaTestHelper(schemaWithoutRequired); | ||
|
||
const testData = { | ||
institutionDetails: { | ||
institutionName: { | ||
valid: 'Institution of Test', | ||
invalid: null, | ||
}, | ||
facilityCode: { | ||
valid: 'IoT 123', | ||
invalid: 123456, | ||
}, | ||
termStartDate: { | ||
valid: '2024-11-25', | ||
invalid: 'start date', | ||
}, | ||
dateOfCalculations: { | ||
valid: '2024-11-28', | ||
invalid: 20241128, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('22-10215 Schema', () => { | ||
it('should have required fields', () => { | ||
expect(schema.required).to.deep.equal('institutionName', 'facilityCode', 'termStartDate', 'dateOfCalculations'); | ||
}); | ||
|
||
schemaTestHelper.testValidAndInvalid('institutionName', testData.institutionName); | ||
schemaTestHelper.testValidAndInvalid('facilityCode', testData.facilityCode); | ||
schemaTestHelper.testValidAndInvalid('termStartDate', testData.termStartDate); | ||
schemaTestHelper.testValidAndInvalid('dateOfCalculations', testData.dateOfCalculations); | ||
}); |