Skip to content

Commit

Permalink
chore: refactor script to build JSON examples (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Jun 27, 2024
1 parent 2fe4ed5 commit e9a827c
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
mv types/* "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}/types"
mkdir -p "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}/examples"
mv examples/*.json "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}/examples"
cp -r examples/**/*.json "$GITHUB_WORKSPACE/v${{ steps.version_check.outputs.version }}/examples"
- name: Checkout Dist Branch
if: steps.version_check.outputs.changed == 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Schema} from '../../types/Schema';
import {Schema} from '../../../types/Schema';

const version = process.env['VERSION'] || '@next';

export const validLDCE: Schema = {
export const lawfulDevelopmentCertificateExisting: Schema = {
data: {
application: {
type: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Schema} from '../../types/Schema';
import {Schema} from '../../../types/Schema';

const version = process.env['VERSION'] || '@next';

export const validLDCP: Schema = {
export const lawfulDevelopmentCertificateProposed: Schema = {
data: {
application: {
type: {
Expand Down
2 changes: 1 addition & 1 deletion examples/data/listedBuildingConsent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Schema} from '../../types/Schema';

const version = process.env['VERSION'] || '@next';

export const validListedBuildingConsent: Schema = {
export const listedBuildingConsent: Schema = {
data: {
user: {
role: 'applicant',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Schema} from '../../types/Schema';
import {Schema} from '../../../types/Schema';

const version = process.env['VERSION'] || '@next';

export const validPlanningPermission: Schema = {
export const planningPermissionFullHouseholder: Schema = {
data: {
application: {
type: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Schema} from '../../types/Schema';
import {Schema} from '../../../types/Schema';

const version = process.env['VERSION'] || '@next';

export const validPriorApproval: Schema = {
export const priorApprovalSolarPanels: Schema = {
data: {
application: {
type: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 15 additions & 15 deletions scripts/build-json-examples.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as fs from 'fs';
import * as path from 'path';
import {validLDCE} from '../examples/data/ldcE';
import {validLDCP} from '../examples/data/ldcP';
import {validListedBuildingConsent} from '../examples/data/listedBuildingConsent';
import {validPlanningPermission} from '../examples/data/planningPermission';
import {validPriorApproval} from '../examples/data/priorApproval';
import {lawfulDevelopmentCertificateExisting} from '../examples/data/lawfulDevelopmentCertificate/existing';
import {lawfulDevelopmentCertificateProposed} from '../examples/data/lawfulDevelopmentCertificate/proposed';
import {listedBuildingConsent} from '../examples/data/listedBuildingConsent';
import {planningPermissionFullHouseholder} from '../examples/data/planningPermission/fullHouseholder';
import {priorApprovalSolarPanels} from '../examples/data/priorApproval/solarPanels';
import {Schema} from '../types/Schema';

interface Example {
Expand All @@ -14,24 +14,24 @@ interface Example {

const examplesToConvert: Example[] = [
{
filename: 'validLawfulDevelopmentCertificateExisting',
data: validLDCE,
filename: 'lawfulDevelopmentCertificate/existing',
data: lawfulDevelopmentCertificateExisting,
},
{
filename: 'validLawfulDevelopmentCertificateProposed',
data: validLDCP,
filename: 'lawfulDevelopmentCertificate/proposed',
data: lawfulDevelopmentCertificateProposed,
},
{
filename: 'validPriorApproval',
data: validPriorApproval,
filename: 'priorApproval/solarPanels',
data: priorApprovalSolarPanels,
},
{
filename: 'validPlanningPermission',
data: validPlanningPermission,
filename: 'planningPermission/fullHouseholder',
data: planningPermissionFullHouseholder,
},
{
filename: 'validListedBuildingConsent',
data: validListedBuildingConsent,
filename: 'listedBuildingConsent',
data: listedBuildingConsent,
},
];

Expand Down
20 changes: 10 additions & 10 deletions tests/usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import addFormats from 'ajv-formats';
import {Validator} from 'jsonschema';
import {describe, expect, test} from 'vitest';

import {validLDCE} from '../examples/data/ldcE';
import {validLDCP} from '../examples/data/ldcP';
import {validListedBuildingConsent} from '../examples/data/listedBuildingConsent';
import {validPlanningPermission} from '../examples/data/planningPermission';
import {validPriorApproval} from '../examples/data/priorApproval';
import {lawfulDevelopmentCertificateExisting} from '../examples/data/lawfulDevelopmentCertificate/existing';
import {lawfulDevelopmentCertificateProposed} from '../examples/data/lawfulDevelopmentCertificate/proposed';
import {listedBuildingConsent} from '../examples/data/listedBuildingConsent';
import {planningPermissionFullHouseholder} from '../examples/data/planningPermission/fullHouseholder';
import {priorApprovalSolarPanels} from '../examples/data/priorApproval/solarPanels';
import generatedSchema from '../schema/schema.json';

const examplesToTest = [
validLDCE,
validLDCP,
validPriorApproval,
validPlanningPermission,
validListedBuildingConsent,
lawfulDevelopmentCertificateExisting,
lawfulDevelopmentCertificateProposed,
listedBuildingConsent,
planningPermissionFullHouseholder,
priorApprovalSolarPanels,
];

describe("parsing using the 'jsonschema' library", () => {
Expand Down

0 comments on commit e9a827c

Please sign in to comment.