From 8e2ee7abf7e8283b547c5a7a2968f83293e6037b Mon Sep 17 00:00:00 2001 From: Matthew Heroux Date: Thu, 2 Nov 2023 07:45:00 -0500 Subject: [PATCH] feat: refactor faker tests (#488) Signed-off-by: hxtree --- libraries/faker-factory/.eslintrc.js | 2 ++ libraries/faker-factory/CHANGELOG.json | 12 ++++++++++++ libraries/faker-factory/CHANGELOG.md | 9 ++++++++- libraries/faker-factory/package.json | 2 +- .../src/{__tests__ => }/faker-factory.test.ts | 8 ++++++-- libraries/faker-factory/src/faker-factory.ts | 2 +- .../{__tests__ => }/generate-fake-data.test.ts | 6 +++--- libraries/faker-factory/src/generate-fake-data.ts | 2 +- .../src/{__tests__ => }/get-json-schemas.test.ts | 13 ++++++++----- libraries/faker-factory/src/index.ts | 5 +++-- .../src/{__tests__ => }/pojo.test.ts | 2 +- .../src/{settings.ts => settings.type.ts} | 4 ++-- libraries/nestjs-modules/CHANGELOG.json | 12 ++++++++++++ libraries/nestjs-modules/CHANGELOG.md | 7 ++++++- libraries/nestjs-modules/package.json | 2 +- services/authentication-service/CHANGELOG.json | 15 +++++++++++++++ services/authentication-service/CHANGELOG.md | 7 ++++++- services/authentication-service/package.json | 2 +- services/email-service/CHANGELOG.json | 12 ++++++++++++ services/email-service/CHANGELOG.md | 7 ++++++- services/email-service/package.json | 2 +- services/html-to-pdf/CHANGELOG.json | 12 ++++++++++++ services/html-to-pdf/CHANGELOG.md | 7 ++++++- services/html-to-pdf/package.json | 2 +- 24 files changed, 127 insertions(+), 27 deletions(-) rename libraries/faker-factory/src/{__tests__ => }/faker-factory.test.ts (94%) rename libraries/faker-factory/src/{__tests__ => }/generate-fake-data.test.ts (88%) rename libraries/faker-factory/src/{__tests__ => }/get-json-schemas.test.ts (86%) rename libraries/faker-factory/src/{__tests__ => }/pojo.test.ts (93%) rename libraries/faker-factory/src/{settings.ts => settings.type.ts} (95%) diff --git a/libraries/faker-factory/.eslintrc.js b/libraries/faker-factory/.eslintrc.js index 977701a38..a99dbc9b5 100644 --- a/libraries/faker-factory/.eslintrc.js +++ b/libraries/faker-factory/.eslintrc.js @@ -5,5 +5,7 @@ module.exports = { }, rules: { 'no-prototype-builtins': 'off', + 'global-require': 'off', + '@typescript-eslint/no-var-requires': 'off', }, }; diff --git a/libraries/faker-factory/CHANGELOG.json b/libraries/faker-factory/CHANGELOG.json index 1b48787f3..d7db0ba75 100644 --- a/libraries/faker-factory/CHANGELOG.json +++ b/libraries/faker-factory/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/faker-factory", "entries": [ + { + "version": "1.2.1", + "tag": "@cats-cradle/faker-factory_v1.2.1", + "date": "Thu, 02 Nov 2023 12:35:11 GMT", + "comments": { + "patch": [ + { + "comment": "refactor tests" + } + ] + } + }, { "version": "1.2.0", "tag": "@cats-cradle/faker-factory_v1.2.0", diff --git a/libraries/faker-factory/CHANGELOG.md b/libraries/faker-factory/CHANGELOG.md index ca32f5026..7317595aa 100644 --- a/libraries/faker-factory/CHANGELOG.md +++ b/libraries/faker-factory/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @cats-cradle/faker-factory -This log was last generated on Wed, 01 Nov 2023 04:48:36 GMT and should not be manually modified. +This log was last generated on Thu, 02 Nov 2023 12:35:11 GMT and should not be manually modified. + +## 1.2.1 +Thu, 02 Nov 2023 12:35:11 GMT + +### Patches + +- refactor tests ## 1.2.0 Wed, 01 Nov 2023 04:48:36 GMT diff --git a/libraries/faker-factory/package.json b/libraries/faker-factory/package.json index 2bd0b6d9c..b79da358e 100644 --- a/libraries/faker-factory/package.json +++ b/libraries/faker-factory/package.json @@ -1,6 +1,6 @@ { "name": "@cats-cradle/faker-factory", - "version": "1.2.0", + "version": "1.2.1", "main": "./dist/index.js", "repository": { "type": "git", diff --git a/libraries/faker-factory/src/__tests__/faker-factory.test.ts b/libraries/faker-factory/src/faker-factory.test.ts similarity index 94% rename from libraries/faker-factory/src/__tests__/faker-factory.test.ts rename to libraries/faker-factory/src/faker-factory.test.ts index 0f77d0af7..30069f511 100644 --- a/libraries/faker-factory/src/__tests__/faker-factory.test.ts +++ b/libraries/faker-factory/src/faker-factory.test.ts @@ -1,5 +1,9 @@ -import { FakerFactory } from '../faker-factory'; -import { SampleClass, SampleChildClass, SampleEnum } from './sample-class'; +import { FakerFactory } from './faker-factory'; +import { + SampleClass, + SampleChildClass, + SampleEnum, +} from './__tests__/sample-class'; describe('FakerFactory', () => { describe('create', () => { diff --git a/libraries/faker-factory/src/faker-factory.ts b/libraries/faker-factory/src/faker-factory.ts index ec81026b5..58a14d095 100644 --- a/libraries/faker-factory/src/faker-factory.ts +++ b/libraries/faker-factory/src/faker-factory.ts @@ -1,6 +1,6 @@ import { ClassConstructor, plainToInstance } from 'class-transformer'; import { cloneDeep } from 'lodash'; -import { Settings } from './settings'; +import { Settings } from './settings.type'; import { generateFakeData } from './generate-fake-data'; import { getJsonSchemas } from './get-json-schemas'; import { toPojo } from './pojo'; diff --git a/libraries/faker-factory/src/__tests__/generate-fake-data.test.ts b/libraries/faker-factory/src/generate-fake-data.test.ts similarity index 88% rename from libraries/faker-factory/src/__tests__/generate-fake-data.test.ts rename to libraries/faker-factory/src/generate-fake-data.test.ts index 63ad5ddf7..d2f26631e 100644 --- a/libraries/faker-factory/src/__tests__/generate-fake-data.test.ts +++ b/libraries/faker-factory/src/generate-fake-data.test.ts @@ -1,6 +1,6 @@ -import { generateFakeData } from '../generate-fake-data'; -import { SampleClass } from './sample-class'; -import { getJsonSchemas } from '../get-json-schemas'; +import { generateFakeData } from './generate-fake-data'; +import { SampleClass } from './__tests__/sample-class'; +import { getJsonSchemas } from './get-json-schemas'; describe('generateFakeData', () => { it('should change to schema and back again correctly', async () => { diff --git a/libraries/faker-factory/src/generate-fake-data.ts b/libraries/faker-factory/src/generate-fake-data.ts index cb5ef229d..8f44a9754 100644 --- a/libraries/faker-factory/src/generate-fake-data.ts +++ b/libraries/faker-factory/src/generate-fake-data.ts @@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash'; import { JSONSchemaFaker } from 'json-schema-faker'; import currency from 'currency.js'; import { faker } from '@faker-js/faker'; -import { Settings, defaultSettings } from './settings'; +import { Settings, defaultSettings } from './settings.type'; /** * Determines how JSONSchema is faked based on format, pattern, etc. diff --git a/libraries/faker-factory/src/__tests__/get-json-schemas.test.ts b/libraries/faker-factory/src/get-json-schemas.test.ts similarity index 86% rename from libraries/faker-factory/src/__tests__/get-json-schemas.test.ts rename to libraries/faker-factory/src/get-json-schemas.test.ts index 211442225..c9c88ae93 100644 --- a/libraries/faker-factory/src/__tests__/get-json-schemas.test.ts +++ b/libraries/faker-factory/src/get-json-schemas.test.ts @@ -1,7 +1,10 @@ // eslint-disable-next-line max-classes-per-file -import { Type } from 'class-transformer'; -import { IsString, ValidateNested } from 'class-validator'; -import { getJsonSchemas } from '../get-json-schemas'; +import { + Type, + IsString, + ValidateNested, +} from '@cats-cradle/validation-schemas'; +import { getJsonSchemas } from './get-json-schemas'; describe('getJsonSchemas', () => { it.each([ @@ -11,7 +14,7 @@ describe('getJsonSchemas', () => { ])( 'should determine "%s" property to have JSONSchema format "%s"', async (property: string, value: any) => { - const { SampleClass } = require('./sample-class'); + const { SampleClass } = require('./__tests__/sample-class'); const schemas = getJsonSchemas(); expect(schemas.SampleClass.properties).toHaveProperty( property, @@ -29,7 +32,7 @@ describe('getJsonSchemas', () => { ])( 'should determine "%s" property to have JSONSchema pattern "%s"', async (property: string, value: string) => { - const { SampleClass } = require('./sample-class'); + const { SampleClass } = require('./__tests__/sample-class'); const schemas = getJsonSchemas(); expect(schemas.SampleClass.properties).toHaveProperty(property); expect(schemas.SampleClass.properties).toHaveProperty( diff --git a/libraries/faker-factory/src/index.ts b/libraries/faker-factory/src/index.ts index 8411a89dd..761aa08ca 100644 --- a/libraries/faker-factory/src/index.ts +++ b/libraries/faker-factory/src/index.ts @@ -1,3 +1,4 @@ -export * from './faker-factory'; +export { Settings } from './settings.type'; +export { FakerFactory } from './faker-factory'; export { toPojo, isPojo } from './pojo'; -export { Settings } from './settings'; +export { getJsonSchemas } from './get-json-schemas'; diff --git a/libraries/faker-factory/src/__tests__/pojo.test.ts b/libraries/faker-factory/src/pojo.test.ts similarity index 93% rename from libraries/faker-factory/src/__tests__/pojo.test.ts rename to libraries/faker-factory/src/pojo.test.ts index 9b14f885c..399e9a5df 100644 --- a/libraries/faker-factory/src/__tests__/pojo.test.ts +++ b/libraries/faker-factory/src/pojo.test.ts @@ -1,4 +1,4 @@ -import { isPojo, toPojo } from '../pojo'; +import { isPojo, toPojo } from './pojo'; class TestClass { a: string; diff --git a/libraries/faker-factory/src/settings.ts b/libraries/faker-factory/src/settings.type.ts similarity index 95% rename from libraries/faker-factory/src/settings.ts rename to libraries/faker-factory/src/settings.type.ts index ba280c7c4..740685499 100644 --- a/libraries/faker-factory/src/settings.ts +++ b/libraries/faker-factory/src/settings.type.ts @@ -1,4 +1,4 @@ -export interface Settings { +export type Settings = { /** * whether optional properties are faked: * true for always generate @@ -23,7 +23,7 @@ export interface Settings { additionalProperties?: boolean | undefined; ignoreProperties?: boolean | undefined; -} +}; export const defaultSettings: Settings = { probability: 0.5, diff --git a/libraries/nestjs-modules/CHANGELOG.json b/libraries/nestjs-modules/CHANGELOG.json index 5ea12a614..f68b028ef 100644 --- a/libraries/nestjs-modules/CHANGELOG.json +++ b/libraries/nestjs-modules/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/nestjs-modules", "entries": [ + { + "version": "0.2.7", + "tag": "@cats-cradle/nestjs-modules_v0.2.7", + "date": "Thu, 02 Nov 2023 12:35:11 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.2.1`" + } + ] + } + }, { "version": "0.2.6", "tag": "@cats-cradle/nestjs-modules_v0.2.6", diff --git a/libraries/nestjs-modules/CHANGELOG.md b/libraries/nestjs-modules/CHANGELOG.md index 4c753b6a2..aa1bd5fe5 100644 --- a/libraries/nestjs-modules/CHANGELOG.md +++ b/libraries/nestjs-modules/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/nestjs-modules -This log was last generated on Wed, 01 Nov 2023 04:48:36 GMT and should not be manually modified. +This log was last generated on Thu, 02 Nov 2023 12:35:11 GMT and should not be manually modified. + +## 0.2.7 +Thu, 02 Nov 2023 12:35:11 GMT + +_Version update only_ ## 0.2.6 Wed, 01 Nov 2023 04:48:36 GMT diff --git a/libraries/nestjs-modules/package.json b/libraries/nestjs-modules/package.json index f26ffbac3..2e32c580e 100644 --- a/libraries/nestjs-modules/package.json +++ b/libraries/nestjs-modules/package.json @@ -1,6 +1,6 @@ { "name": "@cats-cradle/nestjs-modules", - "version": "0.2.6", + "version": "0.2.7", "main": "./dist/index.js", "repository": { "type": "git", diff --git a/services/authentication-service/CHANGELOG.json b/services/authentication-service/CHANGELOG.json index 4fbb7cbec..c524582a1 100644 --- a/services/authentication-service/CHANGELOG.json +++ b/services/authentication-service/CHANGELOG.json @@ -1,6 +1,21 @@ { "name": "@cats-cradle/authentication-service", "entries": [ + { + "version": "1.0.8", + "tag": "@cats-cradle/authentication-service_v1.0.8", + "date": "Thu, 02 Nov 2023 12:35:11 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/nestjs-modules\" to `0.2.7`" + }, + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.2.1`" + } + ] + } + }, { "version": "1.0.7", "tag": "@cats-cradle/authentication-service_v1.0.7", diff --git a/services/authentication-service/CHANGELOG.md b/services/authentication-service/CHANGELOG.md index a8d491ac0..0266a91b8 100644 --- a/services/authentication-service/CHANGELOG.md +++ b/services/authentication-service/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/authentication-service -This log was last generated on Wed, 01 Nov 2023 04:48:36 GMT and should not be manually modified. +This log was last generated on Thu, 02 Nov 2023 12:35:11 GMT and should not be manually modified. + +## 1.0.8 +Thu, 02 Nov 2023 12:35:11 GMT + +_Version update only_ ## 1.0.7 Wed, 01 Nov 2023 04:48:36 GMT diff --git a/services/authentication-service/package.json b/services/authentication-service/package.json index d25c20574..78b46771d 100644 --- a/services/authentication-service/package.json +++ b/services/authentication-service/package.json @@ -1,7 +1,7 @@ { "name": "@cats-cradle/authentication-service", "module": "commonjs", - "version": "1.0.7", + "version": "1.0.8", "scripts": { "dev": "nest start --debug --watch", "build": "tsc", diff --git a/services/email-service/CHANGELOG.json b/services/email-service/CHANGELOG.json index 2e2602752..b559e4bda 100644 --- a/services/email-service/CHANGELOG.json +++ b/services/email-service/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/email-service", "entries": [ + { + "version": "0.0.15", + "tag": "@cats-cradle/email-service_v0.0.15", + "date": "Thu, 02 Nov 2023 12:35:11 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.2.1`" + } + ] + } + }, { "version": "0.0.14", "tag": "@cats-cradle/email-service_v0.0.14", diff --git a/services/email-service/CHANGELOG.md b/services/email-service/CHANGELOG.md index b57b6644f..cbc4c73cd 100644 --- a/services/email-service/CHANGELOG.md +++ b/services/email-service/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/email-service -This log was last generated on Wed, 01 Nov 2023 04:48:36 GMT and should not be manually modified. +This log was last generated on Thu, 02 Nov 2023 12:35:11 GMT and should not be manually modified. + +## 0.0.15 +Thu, 02 Nov 2023 12:35:11 GMT + +_Version update only_ ## 0.0.14 Wed, 01 Nov 2023 04:48:36 GMT diff --git a/services/email-service/package.json b/services/email-service/package.json index c5e834939..4fe9604d4 100644 --- a/services/email-service/package.json +++ b/services/email-service/package.json @@ -1,7 +1,7 @@ { "name": "@cats-cradle/email-service", "module": "commonjs", - "version": "0.0.14", + "version": "0.0.15", "scripts": { "dev": "nest start --debug --watch", "build": "tsc", diff --git a/services/html-to-pdf/CHANGELOG.json b/services/html-to-pdf/CHANGELOG.json index 7cd32e9f6..ca0db0d4f 100644 --- a/services/html-to-pdf/CHANGELOG.json +++ b/services/html-to-pdf/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@cats-cradle/html-to-pdf", "entries": [ + { + "version": "1.0.9", + "tag": "@cats-cradle/html-to-pdf_v1.0.9", + "date": "Thu, 02 Nov 2023 12:35:11 GMT", + "comments": { + "dependency": [ + { + "comment": "Updating dependency \"@cats-cradle/faker-factory\" to `1.2.1`" + } + ] + } + }, { "version": "1.0.8", "tag": "@cats-cradle/html-to-pdf_v1.0.8", diff --git a/services/html-to-pdf/CHANGELOG.md b/services/html-to-pdf/CHANGELOG.md index 31de45c23..f9c06b5af 100644 --- a/services/html-to-pdf/CHANGELOG.md +++ b/services/html-to-pdf/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log - @cats-cradle/html-to-pdf -This log was last generated on Wed, 01 Nov 2023 04:48:36 GMT and should not be manually modified. +This log was last generated on Thu, 02 Nov 2023 12:35:11 GMT and should not be manually modified. + +## 1.0.9 +Thu, 02 Nov 2023 12:35:11 GMT + +_Version update only_ ## 1.0.8 Wed, 01 Nov 2023 04:48:36 GMT diff --git a/services/html-to-pdf/package.json b/services/html-to-pdf/package.json index 48c252604..e85f9eb99 100644 --- a/services/html-to-pdf/package.json +++ b/services/html-to-pdf/package.json @@ -1,7 +1,7 @@ { "name": "@cats-cradle/html-to-pdf", "module": "commonjs", - "version": "1.0.8", + "version": "1.0.9", "license": "MIT", "description": "Your Go-To Solution for PDF Generation from HTML.", "bugs": {