diff --git a/Meadowlark-js/packages/meadowlark-core/src/extraction/DocumentInfoExtractor.ts b/Meadowlark-js/packages/meadowlark-core/src/extraction/DocumentInfoExtractor.ts deleted file mode 100644 index 3ae77e27..00000000 --- a/Meadowlark-js/packages/meadowlark-core/src/extraction/DocumentInfoExtractor.ts +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Licensed to the Ed-Fi Alliance under one or more agreements. -// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -// See the LICENSE and NOTICES files in the project root for more information. -import { extractDocumentReferences } from './DocumentReferenceExtractor'; -import { extractDocumentIdentity } from './DocumentIdentityExtractor'; -import { DocumentInfo } from '../model/DocumentInfo'; -import { extractDescriptorValues } from './DescriptorValueExtractor'; -import { SuperclassInfo } from '../model/SuperclassInfo'; -import { DocumentIdentity } from '../model/DocumentIdentity'; -import { ResourceSchema } from '../model/api-schema/ResourceSchema'; -import { deriveSuperclassInfoFrom } from './SuperclassInfoExtractor'; -import { ApiSchema } from '../model/api-schema/ApiSchema'; - -/** - * Extracts document identity and document reference information from the request body. - */ -export async function extractDocumentInfo( - apiSchema: ApiSchema, - resourceSchema: ResourceSchema, - body: object, - requestTimestamp: number, -): Promise { - const documentIdentity: DocumentIdentity = extractDocumentIdentity(resourceSchema, body); - - let superclassInfo: SuperclassInfo | null = null; - if (!resourceSchema.isDescriptor) { - // We need to do this even if we have no body, for deletes - superclassInfo = deriveSuperclassInfoFrom(resourceSchema, documentIdentity); - } - - return { - documentReferences: extractDocumentReferences(apiSchema, resourceSchema, body), - descriptorReferences: extractDescriptorValues(resourceSchema, body), - documentIdentity, - superclassInfo, - requestTimestamp, - }; -} diff --git a/Meadowlark-js/packages/meadowlark-core/src/handler/MetadataHandler.ts b/Meadowlark-js/packages/meadowlark-core/src/handler/MetadataHandler.ts index c216d29b..e4ceda30 100644 --- a/Meadowlark-js/packages/meadowlark-core/src/handler/MetadataHandler.ts +++ b/Meadowlark-js/packages/meadowlark-core/src/handler/MetadataHandler.ts @@ -11,7 +11,9 @@ import { buildBaseUrlFromRequest } from './UrlBuilder'; import { FrontendRequest } from './FrontendRequest'; import { FrontendResponse } from './FrontendResponse'; import { writeDebugStatusToLog, writeErrorToLog, writeRequestToLog } from '../Logger'; -import { projectShortVersion33b } from '../api-schema/ApiSchemaLoader'; + +// TODO: this can be removed when we drop short version from URL +const projectShortVersion33b = 'v3.3b'; interface ExternalResource { body: string; diff --git a/Meadowlark-js/packages/meadowlark-core/src/middleware/ExtractDocumentInfoMiddleware.ts b/Meadowlark-js/packages/meadowlark-core/src/middleware/ExtractDocumentInfoMiddleware.ts index d187f129..f2c01e59 100644 --- a/Meadowlark-js/packages/meadowlark-core/src/middleware/ExtractDocumentInfoMiddleware.ts +++ b/Meadowlark-js/packages/meadowlark-core/src/middleware/ExtractDocumentInfoMiddleware.ts @@ -6,10 +6,43 @@ import { writeDebugStatusToLog, writeRequestToLog } from '../Logger'; import { MiddlewareModel } from './MiddlewareModel'; import { DocumentInfo, NoDocumentInfo } from '../model/DocumentInfo'; -import { extractDocumentInfo } from '../extraction/DocumentInfoExtractor'; +import { extractDescriptorValues } from '../extraction/DescriptorValueExtractor'; +import { extractDocumentIdentity } from '../extraction/DocumentIdentityExtractor'; +import { extractDocumentReferences } from '../extraction/DocumentReferenceExtractor'; +import { deriveSuperclassInfoFrom } from '../extraction/SuperclassInfoExtractor'; +import { DocumentIdentity } from '../model/DocumentIdentity'; +import { SuperclassInfo } from '../model/SuperclassInfo'; +import { ApiSchema } from '../model/api-schema/ApiSchema'; +import { ResourceSchema } from '../model/api-schema/ResourceSchema'; const moduleName = 'core.middleware.ExtractDocumentInfoMiddleware'; +/** + * Builds a DocumentInfo using the various extractors + */ +function buildDocumentInfo( + apiSchema: ApiSchema, + resourceSchema: ResourceSchema, + body: object, + requestTimestamp: number, +): DocumentInfo { + const documentIdentity: DocumentIdentity = extractDocumentIdentity(resourceSchema, body); + + let superclassInfo: SuperclassInfo | null = null; + if (!resourceSchema.isDescriptor) { + // We need to do this even if we have no body, for deletes + superclassInfo = deriveSuperclassInfoFrom(resourceSchema, documentIdentity); + } + + return { + documentReferences: extractDocumentReferences(apiSchema, resourceSchema, body), + descriptorReferences: extractDescriptorValues(resourceSchema, body), + documentIdentity, + superclassInfo, + requestTimestamp, + }; +} + /** * Extracts identity and reference information from a valid JSON document */ @@ -21,8 +54,8 @@ export async function documentInfoExtraction({ if (frontendResponse != null) return { frontendRequest, frontendResponse }; writeRequestToLog(moduleName, frontendRequest, 'documentInfoExtraction'); - const documentInfo: DocumentInfo = await extractDocumentInfo( - frontendRequest.middleware. + const documentInfo: DocumentInfo = buildDocumentInfo( + frontendRequest.middleware.apiSchema, frontendRequest.middleware.resourceSchema, frontendRequest.middleware.parsedBody, frontendRequest.middleware.timestamp, diff --git a/Meadowlark-js/packages/meadowlark-core/src/middleware/ValidateEndpointMiddleware.ts b/Meadowlark-js/packages/meadowlark-core/src/middleware/ValidateEndpointMiddleware.ts index c727ca54..6ba0ee5a 100644 --- a/Meadowlark-js/packages/meadowlark-core/src/middleware/ValidateEndpointMiddleware.ts +++ b/Meadowlark-js/packages/meadowlark-core/src/middleware/ValidateEndpointMiddleware.ts @@ -19,6 +19,7 @@ export async function endpointValidation({ frontendRequest, frontendResponse }: writeRequestToLog(moduleName, frontendRequest, 'resourceValidation'); const { resourceSchema, resourceInfo, errorBody, headerMetadata } = await validateEndpoint( + frontendRequest.middleware.apiSchema, frontendRequest.middleware.pathComponents, frontendRequest.traceId, ); diff --git a/Meadowlark-js/packages/meadowlark-core/test/extraction/DocumentInfoExtractor.test.ts b/Meadowlark-js/packages/meadowlark-core/test/extraction/DocumentInfoExtractor.test.ts deleted file mode 100644 index 0d438708..00000000 --- a/Meadowlark-js/packages/meadowlark-core/test/extraction/DocumentInfoExtractor.test.ts +++ /dev/null @@ -1,260 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Licensed to the Ed-Fi Alliance under one or more agreements. -// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -// See the LICENSE and NOTICES files in the project root for more information. -import { newEntityProperty, newTopLevelEntity, TopLevelEntity } from '@edfi/metaed-core'; -import { ResourceInfo, newResourceInfo } from '../../src/model/ResourceInfo'; -import { DocumentInfo } from '../../src/model/DocumentInfo'; -import { DescriptorDocument } from '../../src/model/DescriptorDocument'; -import { extractDocumentInfo } from '../../src/extraction/DocumentInfoExtractor'; -import { DocumentIdentity } from '../../src/model/DocumentIdentity'; -import { DocumentObjectKey } from '../../src/model/api-schema/DocumentObjectKey'; - -const requestTimestamp = 10; - -const testModel = (): TopLevelEntity => ({ - ...newTopLevelEntity(), - metaEdName: 'Student', - properties: [ - { ...newEntityProperty(), metaEdName: 'uniqueId', isPartOfIdentity: true }, - { ...newEntityProperty(), metaEdName: 'someBooleanParameter', isPartOfIdentity: false }, - { ...newEntityProperty(), metaEdName: 'someIntegerParameter', isPartOfIdentity: false }, - { ...newEntityProperty(), metaEdName: 'someDecimalParameter', isPartOfIdentity: false }, - ], - data: { - edfiApiSchema: { - apiMapping: { - identityReferenceComponents: [], - referenceGroups: [], - descriptorCollectedApiProperties: [], - }, - jsonSchemaForInsert: { - $schema: 'https://json-schema.org/draft/2020-12/schema', - additionalProperties: false, - description: 'doc', - properties: { - uniqueId: { - description: 'doc', - maxLength: 30, - type: 'string', - }, - someBooleanParameter: { - description: 'doc', - type: 'boolean', - }, - someIntegerParameter: { - description: 'doc', - type: 'integer', - }, - someDecimalParameter: { - description: 'doc', - type: 'number', - }, - }, - required: ['uniqueId'], - title: 'EdFi.Student', - type: 'object', - }, - jsonSchemaForUpdate: { - $schema: 'https://json-schema.org/draft/2020-12/schema', - additionalProperties: false, - description: 'doc', - properties: { - uniqueId: { - description: 'doc', - maxLength: 30, - type: 'string', - }, - someBooleanParameter: { - description: 'doc', - type: 'boolean', - }, - someIntegerParameter: { - description: 'doc', - type: 'integer', - }, - someDecimalParameter: { - description: 'doc', - type: 'number', - }, - }, - required: ['uniqueId'], - title: 'EdFi.Student', - type: 'object', - }, - }, - }, -}); - -const testSchoolModel = (): TopLevelEntity => ({ - ...newTopLevelEntity(), - metaEdName: 'Student', - properties: [ - { ...newEntityProperty(), metaEdName: 'uniqueId', isPartOfIdentity: true }, - { ...newEntityProperty(), metaEdName: 'someBooleanParameter', isPartOfIdentity: false }, - { ...newEntityProperty(), metaEdName: 'someIntegerParameter', isPartOfIdentity: false }, - { ...newEntityProperty(), metaEdName: 'someDecimalParameter', isPartOfIdentity: false }, - ], - data: { - edfiApiSchema: { - apiMapping: { - identityReferenceComponents: [], - referenceGroups: [], - descriptorCollectedApiProperties: [], - superclass: { - metaEdName: 'School', - documentIdentity: { schoolYear: '2023' }, - namespace: { - projectName: 'Testing', - }, - resourceName: 'School', - }, - }, - jsonSchemaForInsert: { - $schema: 'https://json-schema.org/draft/2020-12/schema', - additionalProperties: false, - description: 'doc', - properties: { - uniqueId: { - description: 'doc', - maxLength: 30, - type: 'string', - }, - someBooleanParameter: { - description: 'doc', - type: 'boolean', - }, - someIntegerParameter: { - description: 'doc', - type: 'integer', - }, - someDecimalParameter: { - description: 'doc', - type: 'number', - }, - }, - required: ['uniqueId'], - title: 'EdFi.Student', - type: 'object', - }, - jsonSchemaForUpdate: { - $schema: 'https://json-schema.org/draft/2020-12/schema', - additionalProperties: false, - description: 'doc', - properties: { - id: { - description: 'The item id', - type: 'string', - }, - uniqueId: { - description: 'doc', - maxLength: 30, - type: 'string', - }, - someBooleanParameter: { - description: 'doc', - type: 'boolean', - }, - someIntegerParameter: { - description: 'doc', - type: 'integer', - }, - someDecimalParameter: { - description: 'doc', - type: 'number', - }, - }, - required: ['id', 'uniqueId'], - title: 'EdFi.Student', - type: 'object', - }, - }, - }, -}); - -describe('given IsDescriptor equal true', () => { - const body: DocumentIdentity = [{ documentKey: 'schoolYear' as DocumentObjectKey, documentValue: '2023' }], - const matchingMetaEdModel: TopLevelEntity = { - ...testModel(), - }; - let queryResult: DocumentInfo; - const resourceInfoRequest: ResourceInfo = { - ...newResourceInfo(), - isDescriptor: true, - }; - beforeAll(async () => { - queryResult = await extractDocumentInfo(resourceInfoRequest, body, matchingMetaEdModel, requestTimestamp); - }); - it('should return documentInfo.', async () => { - // Assert - expect(queryResult).toEqual({ - descriptorReferences: [], - documentIdentity: {}, - documentReferences: [], - superclassInfo: null, - requestTimestamp, - }); - }); -}); - -describe('given isDescriptor False', () => { - const body: DescriptorDocument = { - namespace: 'namespace', - codeValue: 'codeValue', - shortDescription: 'shortDescription', - }; - const matchingMetaEdModel: TopLevelEntity = { - ...testModel(), - }; - let queryResult: DocumentInfo; - const resourceInfoRequest: ResourceInfo = { - ...newResourceInfo(), - isDescriptor: false, - }; - beforeAll(async () => { - queryResult = await extractDocumentInfo(resourceInfoRequest, body, matchingMetaEdModel, requestTimestamp); - }); - it('should return superclass null.', async () => { - // Assert - expect(queryResult).toEqual({ - descriptorReferences: [], - documentIdentity: {}, - documentReferences: [], - superclassInfo: null, - requestTimestamp, - }); - }); -}); - -describe('given isDescriptor False', () => { - const body: DescriptorDocument = { - namespace: 'namespace', - codeValue: 'codeValue', - shortDescription: 'shortDescription', - }; - const matchingMetaEdModel: TopLevelEntity = { - ...testSchoolModel(), - }; - let queryResult: DocumentInfo; - const resourceInfoRequest: ResourceInfo = { - ...newResourceInfo(), - isDescriptor: false, - }; - beforeAll(async () => { - queryResult = await extractDocumentInfo(resourceInfoRequest, body, matchingMetaEdModel, requestTimestamp); - }); - it('should return superclass.', async () => { - // Assert - expect(queryResult).toEqual({ - descriptorReferences: [], - documentIdentity: {}, - documentReferences: [], - superclassInfo: { - documentIdentity: {}, - projectName: 'Testing', - resourceName: 'School', - }, - requestTimestamp, - }); - }); -}); diff --git a/Meadowlark-js/packages/meadowlark-core/test/middleware/ExtractDocumentInfoMiddleware.test.ts b/Meadowlark-js/packages/meadowlark-core/test/middleware/ExtractDocumentInfoMiddleware.test.ts index bf80b02e..e1a88cb2 100644 --- a/Meadowlark-js/packages/meadowlark-core/test/middleware/ExtractDocumentInfoMiddleware.test.ts +++ b/Meadowlark-js/packages/meadowlark-core/test/middleware/ExtractDocumentInfoMiddleware.test.ts @@ -3,7 +3,6 @@ // The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. // See the LICENSE and NOTICES files in the project root for more information. -import * as DocumentInfoExtractor from '../../src/extraction/DocumentInfoExtractor'; import { documentInfoExtraction } from '../../src/middleware/ExtractDocumentInfoMiddleware'; import { FrontendResponse, newFrontendResponse } from '../../src/handler/FrontendResponse'; import { FrontendRequest, newFrontendRequest } from '../../src/handler/FrontendRequest'; diff --git a/Meadowlark-js/packages/meadowlark-core/test/middleware/ValidateDocumentMiddleware.test.ts b/Meadowlark-js/packages/meadowlark-core/test/middleware/ValidateDocumentMiddleware.test.ts index 82fedf52..be84290b 100644 --- a/Meadowlark-js/packages/meadowlark-core/test/middleware/ValidateDocumentMiddleware.test.ts +++ b/Meadowlark-js/packages/meadowlark-core/test/middleware/ValidateDocumentMiddleware.test.ts @@ -100,7 +100,7 @@ describe('given a valid response from documentValidation for Insert', () => { let mockDocumentValidator: any; beforeAll(async () => { - mockDocumentValidator = jest.spyOn(DocumentValidator, 'validateDocument').mockReturnValue(Promise.resolve(null)); + mockDocumentValidator = jest.spyOn(DocumentValidator, 'validateDocument').mockReturnValue(null); // Act resultChain = await documentValidation({ frontendRequest, frontendResponse: null }); diff --git a/Meadowlark-js/packages/meadowlark-core/test/validation/ResourceValidator.test.ts b/Meadowlark-js/packages/meadowlark-core/test/validation/EndpointValidator.test.ts similarity index 100% rename from Meadowlark-js/packages/meadowlark-core/test/validation/ResourceValidator.test.ts rename to Meadowlark-js/packages/meadowlark-core/test/validation/EndpointValidator.test.ts diff --git a/Meadowlark-js/packages/meadowlark-core/test/validation/ReferenceAndIdentityEquivalence.test.ts b/Meadowlark-js/packages/meadowlark-core/test/validation/ReferenceAndIdentityEquivalence.test.ts index 19584aee..7c28573c 100644 --- a/Meadowlark-js/packages/meadowlark-core/test/validation/ReferenceAndIdentityEquivalence.test.ts +++ b/Meadowlark-js/packages/meadowlark-core/test/validation/ReferenceAndIdentityEquivalence.test.ts @@ -3,6 +3,8 @@ // The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. // See the LICENSE and NOTICES files in the project root for more information. +/* eslint-disable dot-notation */ + import { newMetaEdEnvironment, MetaEdEnvironment, @@ -22,14 +24,16 @@ import { import { extractDocumentReferences } from '../../src/extraction/DocumentReferenceExtractor'; import { extractDocumentIdentity } from '../../src/extraction/DocumentIdentityExtractor'; import { DocumentReference } from '../../src/model/DocumentReference'; -import { DocumentIdentity, NoDocumentIdentity } from '../../src/model/DocumentIdentity'; +import { DocumentIdentity } from '../../src/model/DocumentIdentity'; +import { ApiSchema } from '../../src/model/api-schema/ApiSchema'; +import { ResourceSchema } from '../../src/model/api-schema/ResourceSchema'; +import { apiSchemaFrom } from '../TestHelper'; describe('when comparing identities with references from domain entity referencing one as identity and another as collection', () => { const metaEd: MetaEdEnvironment = newMetaEdEnvironment(); - let namespace: any = null; let referenceExtractionResult: DocumentReference[] = []; - let classPeriodIdentityExtractionResult: DocumentIdentity = NoDocumentIdentity; - let courseOfferingIdentityExtractionResult: DocumentIdentity = NoDocumentIdentity; + let classPeriodIdentityExtractionResult: DocumentIdentity = []; + let courseOfferingIdentityExtractionResult: DocumentIdentity = []; const bodyWithReferences = { sectionIdentifier: 'Bob', @@ -105,31 +109,34 @@ describe('when comparing identities with references from domain entity referenci propertyCollectingEnhancer(metaEd); apiEntityMappingEnhancer(metaEd); - namespace = metaEd.namespace.get('EdFi'); - const section = namespace.entity.domainEntity.get('Section'); - referenceExtractionResult = extractDocumentReferences(section, bodyWithReferences); - const classPeriod = namespace.entity.domainEntity.get('ClassPeriod'); - classPeriodIdentityExtractionResult = extractDocumentIdentity(classPeriod, classPeriodIdentityBody); - const courseOffering = namespace.entity.domainEntity.get('CourseOffering'); - courseOfferingIdentityExtractionResult = extractDocumentIdentity(courseOffering, courseOfferingIdentityBody); + const apiSchema: ApiSchema = apiSchemaFrom(metaEd); + const sectionResourceSchema: ResourceSchema = apiSchema.projectSchemas['edfi'].resourceSchemas['sections']; + const classPeriodResourceSchema: ResourceSchema = apiSchema.projectSchemas['edfi'].resourceSchemas['classPeriods']; + const courseOfferingResourceSchema: ResourceSchema = apiSchema.projectSchemas['edfi'].resourceSchemas['courseOfferings']; + + referenceExtractionResult = extractDocumentReferences(apiSchema, sectionResourceSchema, bodyWithReferences); + classPeriodIdentityExtractionResult = extractDocumentIdentity(classPeriodResourceSchema, classPeriodIdentityBody); + courseOfferingIdentityExtractionResult = extractDocumentIdentity( + courseOfferingResourceSchema, + courseOfferingIdentityBody, + ); }); it('should have classPeriod reference and identity match', () => { - const [classPeriodReferenceExtractonResult] = referenceExtractionResult; - expect(classPeriodReferenceExtractonResult.documentIdentity).toEqual(classPeriodIdentityExtractionResult); + const [, classPeriodReferenceExtractionResult] = referenceExtractionResult; + expect(classPeriodReferenceExtractionResult.documentIdentity).toEqual(classPeriodIdentityExtractionResult); }); it('should have courseOffering reference and identity match', () => { - const [, , courseOfferingReferenceExtractonResult] = referenceExtractionResult; - expect(courseOfferingReferenceExtractonResult.documentIdentity).toEqual(courseOfferingIdentityExtractionResult); + const [courseOfferingReferenceExtractionResult] = referenceExtractionResult; + expect(courseOfferingReferenceExtractionResult.documentIdentity).toEqual(courseOfferingIdentityExtractionResult); }); }); describe('when comparing identities with references with three levels of identities on a collection reference', () => { const metaEd: MetaEdEnvironment = newMetaEdEnvironment(); - let namespace: any = null; let referenceExtractionResult: DocumentReference[] = []; - let classPeriodIdentityExtractionResult: DocumentIdentity = NoDocumentIdentity; + let classPeriodIdentityExtractionResult: DocumentIdentity = []; const bodyWithReferences = { sectionIdentifier: 'Bob', @@ -218,24 +225,24 @@ describe('when comparing identities with references with three levels of identit propertyCollectingEnhancer(metaEd); apiEntityMappingEnhancer(metaEd); - namespace = metaEd.namespace.get('EdFi'); - const section = namespace.entity.domainEntity.get('Section'); - referenceExtractionResult = extractDocumentReferences(section, bodyWithReferences); - const classPeriod = namespace.entity.domainEntity.get('ClassPeriod'); - classPeriodIdentityExtractionResult = extractDocumentIdentity(classPeriod, classPeriodIdentityBody); + const apiSchema: ApiSchema = apiSchemaFrom(metaEd); + const sectionResourceSchema: ResourceSchema = apiSchema.projectSchemas['edfi'].resourceSchemas['sections']; + const classPeriodResourceSchema: ResourceSchema = apiSchema.projectSchemas['edfi'].resourceSchemas['classPeriods']; + + referenceExtractionResult = extractDocumentReferences(apiSchema, sectionResourceSchema, bodyWithReferences); + classPeriodIdentityExtractionResult = extractDocumentIdentity(classPeriodResourceSchema, classPeriodIdentityBody); }); it('should have classPeriod reference and identity match', () => { - const [classPeriodReferenceExtractonResult] = referenceExtractionResult; - expect(classPeriodReferenceExtractonResult.documentIdentity).toEqual(classPeriodIdentityExtractionResult); + const [classPeriodReferenceExtractionResult] = referenceExtractionResult; + expect(classPeriodReferenceExtractionResult.documentIdentity).toEqual(classPeriodIdentityExtractionResult); }); }); describe('when comparing identities with references with two levels of identities with a merge on School', () => { const metaEd: MetaEdEnvironment = newMetaEdEnvironment(); - let namespace: any = null; let referenceExtractionResult: DocumentReference[] = []; - let classPeriodIdentityExtractionResult: DocumentIdentity = NoDocumentIdentity; + let classPeriodIdentityExtractionResult: DocumentIdentity = []; const bodyWithReferences = { sectionIdentifier: 'Bob', @@ -307,15 +314,16 @@ describe('when comparing identities with references with two levels of identitie propertyCollectingEnhancer(metaEd); apiEntityMappingEnhancer(metaEd); - namespace = metaEd.namespace.get('EdFi'); - const section = namespace.entity.domainEntity.get('Section'); - referenceExtractionResult = extractDocumentReferences(section, bodyWithReferences); - const classPeriod = namespace.entity.domainEntity.get('ClassPeriod'); - classPeriodIdentityExtractionResult = extractDocumentIdentity(classPeriod, classPeriodIdentityBody); + const apiSchema: ApiSchema = apiSchemaFrom(metaEd); + const sectionResourceSchema: ResourceSchema = apiSchema.projectSchemas['edfi'].resourceSchemas['sections']; + const classPeriodResourceSchema: ResourceSchema = apiSchema.projectSchemas['edfi'].resourceSchemas['classPeriods']; + + referenceExtractionResult = extractDocumentReferences(apiSchema, sectionResourceSchema, bodyWithReferences); + classPeriodIdentityExtractionResult = extractDocumentIdentity(classPeriodResourceSchema, classPeriodIdentityBody); }); it('should have classPeriod reference and identity match', () => { - const [classPeriodReferenceExtractonResult] = referenceExtractionResult; - expect(classPeriodReferenceExtractonResult.documentIdentity).toEqual(classPeriodIdentityExtractionResult); + const [classPeriodReferenceExtractionResult] = referenceExtractionResult; + expect(classPeriodReferenceExtractionResult.documentIdentity).toEqual(classPeriodIdentityExtractionResult); }); });