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

Form 10215 #967

Merged
merged 6 commits into from
Dec 16, 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
73 changes: 73 additions & 0 deletions dist/22-10215-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Report 85/15 Rule enrollment ratios",
"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"
}
}
},
"programs": {
"type": "array",
"required": [
"programName",
"studentsEnrolled",
"supportedStudents"
],
"properties": {
"programName": {
"type": "string"
},
"studentsEnrolled": {
"type": "integer"
},
"supportedStudents": {
"type": "integer"
},
"fte": {
"type": "object",
"properties": {
"supported": {
"type": "integer"
},
"nonSupported": {
"type": "integer"
},
"totalFTE": {
"type": "integer"
},
"supportedPercentageFTE": {
"type": "number"
}
}
}
}
}
}
}
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.7.0",
"version": "24.7.1",
"license": "CC0-1.0",
"repository": {
"type": "git",
Expand Down
70 changes: 70 additions & 0 deletions src/schemas/22-10215/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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: 'Report 85/15 Rule enrollment ratios',
type: 'object',
additionalProperties: false,
definitions: pickedDefinitions,
required: ['institutionDetails', 'programs'],
properties: {
institutionDetails: {
type: 'object',
required: ['institutionName', 'facilityCode', 'termStartDate', 'dateOfCalculations'],
properties: {
institutionName: {
type: 'string',
},
facilityCode: {
type: 'string',
},
termStartDate: {
$ref: '#/definitions/date',
},
dateOfCalculations: {
$ref: '#/definitions/date',
},
},
},
programs: {
type: 'array',
items: {
type: 'object',
required: ['programName', 'studentsEnrolled', 'supportedStudents'],
properties: {
programName: {
type: 'string',
},
studentsEnrolled: {
type: 'integer',
},
supportedStudents: {
type: 'integer',
},
fte: {
type: 'object',
properties: {
supported: {
type: 'integer',
},
nonSupported: {
type: 'integer',
},
totalFTE: {
type: 'integer',
},
supportedPercentageFTE: {
type: 'number',
},
},
},
},
},
},
},
};

export default schema;
140 changes: 140 additions & 0 deletions test/schemas/22-10215/schema.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { expect } from 'chai';
import { it } from 'mocha';
import { cloneDeep, omit } from 'lodash';
import schema from '../../../src/schemas/22-10215/schema';
import SchemaTestHelper from '../../support/schema-test-helper';

const schemaClone = cloneDeep(schema);
const schemaTestHelper = new SchemaTestHelper(omit(schemaClone, 'required'));

const testData = {
institutionDetails: {
valid: [
{
institutionName: 'Institution of Test',
facilityCode: '12345678',
termStartDate: '2024-11-25',
dateOfCalculations: '2024-11-28',
},
{
institutionName: 'Institution of Test',
facilityCode: '23456789',
termStartDate: '2024-11-25',
dateOfCalculations: '2024-11-28',
},
],
invalid: [
{
institutionName: null,
facilityCode: 'IoT 123',
termStartDate: '2024-11-25',
dateOfCalculations: '2024-11-28',
},
{
institutionName: 'Institution of Test',
facilityCode: 123456,
termStartDate: '2024-11-25',
dateOfCalculations: '2024-11-28',
},
{
institutionName: 'Institution of Test',
facilityCode: 'IoT 123',
termStartDate: 'start date',
dateOfCalculations: '2024-11-28',
},
{
institutionName: 'Institution of Test',
facilityCode: 'IoT 123',
termStartDate: '2024-11-25',
dateOfCalculations: 20241128,
},
],
},
programs: {
valid: [
[{
programName: 'Computer Science',
studentsEnrolled: 100,
supportedStudents: 80,
fte: {
supported: 20,
nonSupported: 10,
totalFTE: 30,
supportedPercentageFTE: 66.67,
},
}],
[{
programName: 'Computer Science',
studentsEnrolled: 10,
supportedStudents: 8,
}],
],
invalid: [
[{
programName: null,
studentsEnrolled: 100,
supportedStudents: 80,
fte: {
supported: 9.5,
nonSupported: 7,
totalFTE: 80,
supportedPercentageFTE: 62.5,
},
}],
[{
programName: 'Computer Science',
studentsEnrolled: '100',
supportedStudents: 80,
fte: {
supported: 9,
nonSupported: 7,
},
}],
[{
programName: 'Computer Science',
studentsEnrolled: null,
supportedStudents: 80,
fte: {
supported: 50,
nonSupported: 30,
totalFTE: 80,
supportedPercentageFTE: 62.5,
},
}],
[{
programName: 'Computer Science',
studentsEnrolled: 100,
supportedStudents: undefined,
fte: {
supported: 50,
nonSupported: 30,
totalFTE: 80,
supportedPercentageFTE: 62.5,
},
}],
],
},
};

describe('22-10215 Schema', () => {
it('should have required fields', () => {
expect(schema.required).to.deep.equal([
'institutionDetails',
'programs',
]);
expect(schema.properties.institutionDetails.required).to.deep.equal([
'institutionName',
'facilityCode',
'termStartDate',
'dateOfCalculations',
]);
expect(schema.properties.programs.items.required).to.deep.equal([
'programName',
'studentsEnrolled',
'supportedStudents'
]);
});

schemaTestHelper.testValidAndInvalid('institutionDetails', testData.institutionDetails);
schemaTestHelper.testValidAndInvalid('programs', testData.programs);
});
Loading