Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schemas and unit tests for 22-10216 #964

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions dist/22-10216-schema.json
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"
}
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vets-json-schema",
"version": "24.6.2",
"version": "24.6.3",
"license": "CC0-1.0",
"repository": {
"type": "git",
Expand Down
50 changes: 50 additions & 0 deletions src/schemas/22-10216/schema.js
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',
fatmakhan0395 marked this conversation as resolved.
Show resolved Hide resolved
},
dateOfCalculation: {
$ref: '#/definitions/date',
},
},
fatmakhan0395 marked this conversation as resolved.
Show resolved Hide resolved
},
},
};
export default schema;
65 changes: 65 additions & 0 deletions test/schemas/22-10216/schema.spec.js
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);
});
fatmakhan0395 marked this conversation as resolved.
Show resolved Hide resolved
});
Loading