From f296da9312709a0ee4958425be701c8969ac3eda Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Mon, 7 Nov 2022 15:21:05 -0800 Subject: [PATCH] assert { type: 'json' } everywhere --- .../seeders/20211209204301-add-projects.js | 14 +++++++------- src/database/seeders/20211209205139-add-units.js | 4 ++-- src/middleware.js | 2 +- src/models/audit/audit.mock.js | 2 +- src/models/co-benefits/co-benefits.mock.js | 2 +- src/models/file-store/file-store.mock.js | 2 +- src/models/issuances/issuances.mock.js | 2 +- src/models/labelUnits/labelUnits.mock.js | 2 +- src/models/labels/labels.mock.js | 2 +- src/models/locations/locations.mock.js | 2 +- src/models/meta/meta.mock.js | 2 +- src/models/organizations/organizations.mock.js | 2 +- src/models/projects/projects.mock.js | 2 +- src/models/ratings/ratings.mock.js | 2 +- .../related-projects/related-projects.mock.js | 2 +- src/models/simulator/simulator.mock.js | 2 +- src/models/staging/staging.mock.js | 2 +- src/models/units/units.mock.js | 2 +- src/utils/config-loader.js | 2 +- src/utils/helpers.js | 2 +- tests/resources/projects.spec.js | 2 +- tests/resources/staging.spec.js | 2 +- tests/resources/units.spec.js | 2 +- tests/test-fixtures/project-fixtures.js | 4 ++-- tests/test-fixtures/unit-fixtures.js | 4 ++-- 25 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/database/seeders/20211209204301-add-projects.js b/src/database/seeders/20211209204301-add-projects.js index 09f886df..49ff6d52 100644 --- a/src/database/seeders/20211209204301-add-projects.js +++ b/src/database/seeders/20211209204301-add-projects.js @@ -1,12 +1,12 @@ 'use strict'; -import ProjectStub from '../../models/projects/projects.stub.json'; -import CoBenifetStub from '../../models/co-benefits/co-benefits.stub.json'; -import RelatedProjectStub from '../../models/related-projects/related-projects.stub.json'; -import LabelStub from '../../models/labels/labels.stub.json'; -import RatingsStub from '../../models/ratings/ratings.stub.json'; -import IssuanceStub from '../../models/issuances/issuances.stub.json'; -import LocationsStub from '../../models/locations/locations.stub.json'; +import ProjectStub from '../../models/projects/projects.stub.json' assert { type: 'json' }; +import CoBenifetStub from '../../models/co-benefits/co-benefits.stub.json' assert { type: 'json' }; +import RelatedProjectStub from '../../models/related-projects/related-projects.stub.json' assert { type: 'json' }; +import LabelStub from '../../models/labels/labels.stub.json' assert { type: 'json' }; +import RatingsStub from '../../models/ratings/ratings.stub.json' assert { type: 'json' }; +import IssuanceStub from '../../models/issuances/issuances.stub.json' assert { type: 'json' }; +import LocationsStub from '../../models/locations/locations.stub.json' assert { type: 'json' }; export default { // eslint-disable-next-line no-unused-vars diff --git a/src/database/seeders/20211209205139-add-units.js b/src/database/seeders/20211209205139-add-units.js index ce68f87f..9e14ef76 100644 --- a/src/database/seeders/20211209205139-add-units.js +++ b/src/database/seeders/20211209205139-add-units.js @@ -1,7 +1,7 @@ 'use strict'; -import UnitStub from '../../models/units/units.stub.json'; -import LabelUnitStub from '../../models/labelUnits/labelUnits.stub.json'; +import UnitStub from '../../models/units/units.stub.json' assert { type: 'json' }; +import LabelUnitStub from '../../models/labelUnits/labelUnits.stub.json' assert { type: 'json' }; export default { // eslint-disable-next-line no-unused-vars diff --git a/src/middleware.js b/src/middleware.js index 9425debe..488fe349 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -14,7 +14,7 @@ import { assertDataLayerAvailable, assertWalletIsAvailable, } from './utils/data-assertions'; -import packageJson from '../package.json'; +import packageJson from '../package.json' assert { type: 'json' }; import datalayer from './datalayer'; const { API_KEY, READ_ONLY, IS_GOVERNANCE_BODY, USE_SIMULATOR } = diff --git a/src/models/audit/audit.mock.js b/src/models/audit/audit.mock.js index 30ea0de6..737b7e21 100644 --- a/src/models/audit/audit.mock.js +++ b/src/models/audit/audit.mock.js @@ -1,4 +1,4 @@ -import stub from './audit.stub.json'; +import stub from './audit.stub.json' assert { type: 'json' }; export const AuditMock = { findAll: () => stub, diff --git a/src/models/co-benefits/co-benefits.mock.js b/src/models/co-benefits/co-benefits.mock.js index 55e27718..c8e973b3 100644 --- a/src/models/co-benefits/co-benefits.mock.js +++ b/src/models/co-benefits/co-benefits.mock.js @@ -1,4 +1,4 @@ -import stub from './co-benefits.stub.json'; +import stub from './co-benefits.stub.json' assert { type: 'json' }; export const CoBenefitsMock = { findAll: () => stub, diff --git a/src/models/file-store/file-store.mock.js b/src/models/file-store/file-store.mock.js index 901dc1fb..2c0a1e46 100644 --- a/src/models/file-store/file-store.mock.js +++ b/src/models/file-store/file-store.mock.js @@ -1,4 +1,4 @@ -import stub from './file-store.stub.json'; +import stub from './file-store.stub.json' assert { type: 'json' }; export const FileStoreMock = { findAll: () => stub, diff --git a/src/models/issuances/issuances.mock.js b/src/models/issuances/issuances.mock.js index 063795c3..70265eab 100644 --- a/src/models/issuances/issuances.mock.js +++ b/src/models/issuances/issuances.mock.js @@ -1,4 +1,4 @@ -import stub from './issuances.stub.json'; +import stub from './issuances.stub.json' assert { type: 'json' }; export const IssuanceMock = { findAll: () => stub, diff --git a/src/models/labelUnits/labelUnits.mock.js b/src/models/labelUnits/labelUnits.mock.js index 6c35c4f7..a37e0c48 100644 --- a/src/models/labelUnits/labelUnits.mock.js +++ b/src/models/labelUnits/labelUnits.mock.js @@ -1,4 +1,4 @@ -import stub from './labelUnits.stub.json'; +import stub from './labelUnits.stub.json' assert { type: 'json' }; export const LabelUnitsMock = { findAll: () => stub, diff --git a/src/models/labels/labels.mock.js b/src/models/labels/labels.mock.js index 1d6499d0..d945e1a7 100644 --- a/src/models/labels/labels.mock.js +++ b/src/models/labels/labels.mock.js @@ -1,4 +1,4 @@ -import stub from './labels.stub.json'; +import stub from './labels.stub.json' assert { type: 'json' }; export const LabelsMock = { findAll: () => stub, diff --git a/src/models/locations/locations.mock.js b/src/models/locations/locations.mock.js index b720a55e..d5ceb84a 100644 --- a/src/models/locations/locations.mock.js +++ b/src/models/locations/locations.mock.js @@ -1,4 +1,4 @@ -import stub from './locations.stub.json'; +import stub from './locations.stub.json' assert { type: 'json' }; export const LocationMock = { findAll: () => stub, diff --git a/src/models/meta/meta.mock.js b/src/models/meta/meta.mock.js index 2bae4c24..52ef8df1 100644 --- a/src/models/meta/meta.mock.js +++ b/src/models/meta/meta.mock.js @@ -1,4 +1,4 @@ -import stub from './meta.stub.json'; +import stub from './meta.stub.json' assert { type: 'json' }; export const MetaMock = { findAll: () => stub, diff --git a/src/models/organizations/organizations.mock.js b/src/models/organizations/organizations.mock.js index fbff4564..e72e2d20 100644 --- a/src/models/organizations/organizations.mock.js +++ b/src/models/organizations/organizations.mock.js @@ -1,4 +1,4 @@ -import stub from './organizations.stub.json'; +import stub from './organizations.stub.json' assert { type: 'json' }; export const OrganizationMock = { findAll: () => stub, diff --git a/src/models/projects/projects.mock.js b/src/models/projects/projects.mock.js index 4902024a..76e086df 100644 --- a/src/models/projects/projects.mock.js +++ b/src/models/projects/projects.mock.js @@ -1,4 +1,4 @@ -import stub from './projects.stub.json'; +import stub from './projects.stub.json' assert { type: 'json' }; export const ProjectMock = { findAll: ({ limit, offset }) => stub.slice(offset * limit, (offset + 1) * limit), diff --git a/src/models/ratings/ratings.mock.js b/src/models/ratings/ratings.mock.js index 3dc7356d..9e73d508 100644 --- a/src/models/ratings/ratings.mock.js +++ b/src/models/ratings/ratings.mock.js @@ -1,4 +1,4 @@ -import stub from './ratings.stub.json'; +import stub from './ratings.stub.json' assert { type: 'json' }; export const RatingMock = { findAll: () => stub, diff --git a/src/models/related-projects/related-projects.mock.js b/src/models/related-projects/related-projects.mock.js index af21c4d5..cae4b5d3 100644 --- a/src/models/related-projects/related-projects.mock.js +++ b/src/models/related-projects/related-projects.mock.js @@ -1,4 +1,4 @@ -import stub from './related-projects.stub.json'; +import stub from './related-projects.stub.json' assert { type: 'json' }; export const RelatedProjectMock = { findAll: () => stub, diff --git a/src/models/simulator/simulator.mock.js b/src/models/simulator/simulator.mock.js index ee10f672..65b2a0b8 100644 --- a/src/models/simulator/simulator.mock.js +++ b/src/models/simulator/simulator.mock.js @@ -1,4 +1,4 @@ -import stub from './simulator.stub.json'; +import stub from './simulator.stub.json' assert { type: 'json' }; export const SimulatorMock = { findAll: () => stub, diff --git a/src/models/staging/staging.mock.js b/src/models/staging/staging.mock.js index 96d2618c..cb2d1ca1 100644 --- a/src/models/staging/staging.mock.js +++ b/src/models/staging/staging.mock.js @@ -1,4 +1,4 @@ -import stub from './staging.stub.json'; +import stub from './staging.stub.json' assert { type: 'json' }; export const StagingMock = { findAll: () => stub, diff --git a/src/models/units/units.mock.js b/src/models/units/units.mock.js index b27b3782..8703b70b 100644 --- a/src/models/units/units.mock.js +++ b/src/models/units/units.mock.js @@ -1,4 +1,4 @@ -import stub from './units.stub.json'; +import stub from './units.stub.json' assert { type: 'json' }; export const UnitMock = { findAll: ({ limit, offset }) => stub.slice(offset * limit, (offset + 1) * limit), diff --git a/src/utils/config-loader.js b/src/utils/config-loader.js index a5afb83a..dea44378 100644 --- a/src/utils/config-loader.js +++ b/src/utils/config-loader.js @@ -7,7 +7,7 @@ import path from 'path'; import { logger } from '../config/logger.cjs'; import { getDataModelVersion } from './helpers'; -import defaultConfig from './defaultConfig.json'; +import defaultConfig from './defaultConfig.json' assert { type: 'json' }; export const getConfig = _.memoize(() => { const homeDir = os.homedir(); diff --git a/src/utils/helpers.js b/src/utils/helpers.js index cbe17922..758101a7 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -4,7 +4,7 @@ import _ from 'lodash'; import { isPluralized } from './string-utils.js'; import { formatModelAssociationName } from './model-utils.js'; -import packageJson from '../../package.json'; +import packageJson from '../../package.json' assert { type: 'json' }; export const paginationParams = (page, limit) => { if (page === undefined || limit === undefined) { diff --git a/tests/resources/projects.spec.js b/tests/resources/projects.spec.js index dd300271..b2fa78f2 100644 --- a/tests/resources/projects.spec.js +++ b/tests/resources/projects.spec.js @@ -4,7 +4,7 @@ import * as testFixtures from '../test-fixtures'; import sinon from 'sinon'; import datalayer from '../../src/datalayer'; const { expect } = chai; -import newProject from '../test-data/new-project.json'; +import newProject from '../test-data/new-project.json' assert { type: 'json' }; import supertest from 'supertest'; import app from '../../src/server'; import { Organization } from '../../src/models/organizations/index.js'; diff --git a/tests/resources/staging.spec.js b/tests/resources/staging.spec.js index 2b4398be..cd85cb4a 100644 --- a/tests/resources/staging.spec.js +++ b/tests/resources/staging.spec.js @@ -1,6 +1,6 @@ import app from '../../src/server'; import supertest from 'supertest'; -import newProject from '../test-data/new-project.json'; +import newProject from '../test-data/new-project.json' assert { type: 'json' }; import { pullPickListValues } from '../../src/utils/data-loaders'; import { expect } from 'chai'; import { prepareDb } from '../../src/database'; diff --git a/tests/resources/units.spec.js b/tests/resources/units.spec.js index 82b08c14..1c3f4b2d 100644 --- a/tests/resources/units.spec.js +++ b/tests/resources/units.spec.js @@ -8,7 +8,7 @@ import app from '../../src/server'; import * as testFixtures from '../test-fixtures'; import datalayer from '../../src/datalayer'; import { prepareDb } from '../../src/database'; -import newUnit from '../test-data/new-unit.json'; +import newUnit from '../test-data/new-unit.json' assert { type: 'json' }; import { pullPickListValues } from '../../src/utils/data-loaders'; const TEST_WAIT_TIME = datalayer.POLLING_INTERVAL * 2; diff --git a/tests/test-fixtures/project-fixtures.js b/tests/test-fixtures/project-fixtures.js index ff63fa83..c6128250 100644 --- a/tests/test-fixtures/project-fixtures.js +++ b/tests/test-fixtures/project-fixtures.js @@ -5,8 +5,8 @@ import chai from 'chai'; const { expect } = chai; import app from '../../src/server'; -import newProject from '../test-data/new-project.json'; -import updateProjectJson from '../test-data/update-project.json'; +import newProject from '../test-data/new-project.json' assert { type: 'json' }; +import updateProjectJson from '../test-data/update-project.json' assert { type: 'json' }; import { ProjectMirror, Project } from '../../src/models'; export const createNewProject = async (payload = newProject) => { diff --git a/tests/test-fixtures/unit-fixtures.js b/tests/test-fixtures/unit-fixtures.js index c297fee8..0b8b233d 100644 --- a/tests/test-fixtures/unit-fixtures.js +++ b/tests/test-fixtures/unit-fixtures.js @@ -5,8 +5,8 @@ import chai from 'chai'; const { expect } = chai; import app from '../../src/server'; -import newUnit from '../test-data/new-unit.json'; -import updateUnitJson from '../test-data/update-unit.json'; +import newUnit from '../test-data/new-unit.json' assert { type: 'json' }; +import updateUnitJson from '../test-data/update-unit.json' assert { type: 'json' }; import { UnitMirror, Unit } from '../../src/models'; export const createNewUnit = async (payload = newUnit) => {