Skip to content

Commit

Permalink
Now with working tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bagelbits committed Dec 28, 2024
1 parent 78a3ffc commit 501c8b7
Show file tree
Hide file tree
Showing 75 changed files with 2,258 additions and 173 deletions.
1 change: 1 addition & 0 deletions jest.config.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const integrationConfig: Config.InitialOptions = {
displayName: 'Integration Tests',
testRegex: '\\.itest\\.(js|ts)$',
silent: true,
maxWorkers: '50%', // Use 50% of available CPUs
};

console.log('RUNNING INTEGRATION TESTS');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"gen-postman": "npm run bundle-swagger && portman --cliOptionsFile portman-cli.json",
"test": "npm run test:unit && npm run test:integration:local",
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c jest.config.unit.ts",
"test:integration": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c jest.config.integration.ts --detectOpenHandles --forceExit",
"test:integration": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest/bin/jest.js -c jest.config.integration.ts --detectOpenHandles --forceExit --runInBand",
"test:integration:local": "docker compose pull && docker compose build && docker compose run --use-aliases api npm run test:integration"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/models/2014/equipment/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type Equipment = {
_id?: mongoose.Types.ObjectId;
armor_category?: string;
armor_class?: ArmorClass;
capacity?: number;
capacity?: string;
category_range?: string;
contents?: Content[];
cost: Cost;
Expand Down
6 changes: 3 additions & 3 deletions src/models/2014/monster/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type LegendaryAction = {
name: string;
desc: string;
attack_bonus?: number;
damage?: ActionDamage[];
damage?: Damage[];
dc?: DifficultyClass;
};

Expand Down Expand Up @@ -138,7 +138,7 @@ type SpecialAbility = {
name: string;
desc: string;
attack_bonus?: number;
damage?: ActionDamage[];
damage?: Damage[];
dc?: DifficultyClass;
spellcasting?: SpecialAbilitySpellcasting;
usage: SpecialAbilityUsage;
Expand All @@ -149,7 +149,7 @@ type Speed = {
burrow?: string;
climb?: string;
fly?: string;
hover?: string;
hover?: boolean;
swim?: string;
walk?: string;
};
Expand Down
2 changes: 1 addition & 1 deletion src/models/2014/trait/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Proficiency = {
url: string;
};

type ActionDamage = {
export type ActionDamage = {
_id?: boolean;
damage_type: APIReference;
damage_at_character_level: Record<string, string>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import AbilityScore from '../../../models/2014/abilityScore/index.js';
import AbilityScoreController from '../../../controllers/api/2014/abilityScoreController.js';
import AbilityScore from '../../../../models/2014/abilityScore/index.js';
import AbilityScoreController from '../../../../controllers/api/2014/abilityScoreController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import * as ClassController from '../../../controllers/api/2014/classController.js';
import * as ClassController from '../../../../controllers/api/2014/classController.js';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Class from '../../../models/2014/class/index.js';
import Feature from '../../../models/2014/feature/index.js';
import Level from '../../../models/2014/level/index.js';
import Proficiency from '../../../models/2014/proficiency/index.js';
import Spell from '../../../models/2014/spell/index.js';
import Subclass from '../../../models/2014/subclass/index.js';
import Class from '../../../../models/2014/class/index.js';
import Feature from '../../../../models/2014/feature/index.js';
import Level from '../../../../models/2014/level/index.js';
import Proficiency from '../../../../models/2014/proficiency/index.js';
import Spell from '../../../../models/2014/spell/index.js';
import Subclass from '../../../../models/2014/subclass/index.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Condition from '../../../models/2014/condition/index.js';
import ConditionController from '../../../controllers/api/2014/conditionController.js';
import Condition from '../../../../models/2014/condition/index.js';
import ConditionController from '../../../../controllers/api/2014/conditionController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import DamageType from '../../../models/2014/damageType/index.js';
import DamageTypeController from '../../../controllers/api/2014/damageTypeController.js';
import DamageType from '../../../../models/2014/damageType/index.js';
import DamageTypeController from '../../../../controllers/api/2014/damageTypeController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import EquipmentCategory from '../../../models/2014/equipmentCategory/index.js';
import EquipmentCategoryController from '../../../controllers/api/2014/equipmentCategoryController.js';
import EquipmentCategory from '../../../../models/2014/equipmentCategory/index.js';
import EquipmentCategoryController from '../../../../controllers/api/2014/equipmentCategoryController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Equipment from '../../../models/2014/equipment/index.js';
import EquipmentController from '../../../controllers/api/2014/equipmentController.js';
import Equipment from '../../../../models/2014/equipment/index.js';
import EquipmentController from '../../../../controllers/api/2014/equipmentController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Feat from '../../../models/2014/feat/index.js';
import FeatController from '../../../controllers/api/2014/featController.js';
import Feat from '../../../../models/2014/feat/index.js';
import FeatController from '../../../../controllers/api/2014/featController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Feature from '../../../models/2014/feature/index.js';
import FeatureController from '../../../controllers/api/2014/featureController.js';
import Feature from '../../../../models/2014/feature/index.js';
import FeatureController from '../../../../controllers/api/2014/featureController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Language from '../../../models/2014/language/index.js';
import LanguageController from '../../../controllers/api/2014/languageController.js';
import Language from '../../../../models/2014/language/index.js';
import LanguageController from '../../../../controllers/api/2014/languageController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import * as MagicItemController from '../../../controllers/api/2014/magicItemController.js';
import * as MagicItemController from '../../../../controllers/api/2014/magicItemController.js';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import MagicItem from '../../../models/2014/magicItem/index.js';
import MagicItem from '../../../../models/2014/magicItem/index.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import MagicSchool from '../../../models/2014/magicSchool/index.js';
import MagicSchoolController from '../../../controllers/api/2014/magicSchoolController.js';
import MagicSchool from '../../../../models/2014/magicSchool/index.js';
import MagicSchoolController from '../../../../controllers/api/2014/magicSchoolController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import * as MonsterController from '../../../controllers/api/2014/monsterController.js';
import * as MonsterController from '../../../../controllers/api/2014/monsterController.js';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Monster from '../../../models/2014/monster/index.js';
import Monster from '../../../../models/2014/monster/index.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Proficiency from '../../../models/2014/proficiency/index.js';
import ProficiencyController from '../../../controllers/api/2014/proficiencyController.js';
import Proficiency from '../../../../models/2014/proficiency/index.js';
import ProficiencyController from '../../../../controllers/api/2014/proficiencyController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import * as RaceController from '../../../controllers/api/2014/raceController.js';
import * as RaceController from '../../../../controllers/api/2014/raceController.js';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Proficiency from '../../../models/2014/proficiency/index.js';
import Race from '../../../models/2014/race/index.js';
import Subrace from '../../../models/2014/subrace/index.js';
import Trait from '../../../models/2014/trait/index.js';
import Proficiency from '../../../../models/2014/proficiency/index.js';
import Race from '../../../../models/2014/race/index.js';
import Subrace from '../../../../models/2014/subrace/index.js';
import Trait from '../../../../models/2014/trait/index.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as RuleSectionController from '../../../controllers/api/2014/ruleSectionController.js';
import * as RuleSectionController from '../../../../controllers/api/2014/ruleSectionController.js';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import RuleSection from '../../../models/2014/ruleSection/index.js';
import RuleSection from '../../../../models/2014/ruleSection/index.js';
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import * as RulesController from '../../../controllers/api/2014/ruleController.js';
import * as RulesController from '../../../../controllers/api/2014/ruleController.js';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Rule from '../../../models/2014/rule/index.js';
import Rule from '../../../../models/2014/rule/index.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import skill from '../../../models/2014/skill/index.js';
import skillController from '../../../controllers/api/2014/skillController.js';
import skill from '../../../../models/2014/skill/index.js';
import skillController from '../../../../controllers/api/2014/skillController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import * as SpellController from '../../../controllers/api/2014/spellController.js';
import * as SpellController from '../../../../controllers/api/2014/spellController.js';

import { mockNext } from '../../support/requestHelpers.js';
import Spell from '../../../models/2014/spell/index.js';
import { mockNext } from '../../../support/requestHelpers.js';
import Spell from '../../../../models/2014/spell/index.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import * as SubclassController from '../../../controllers/api/2014/subclassController.js';
import * as SubclassController from '../../../../controllers/api/2014/subclassController.js';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Feature from '../../../models/2014/feature/index.js';
import Level from '../../../models/2014/level/index.js';
import Subclass from '../../../models/2014/subclass/index.js';
import Feature from '../../../../models/2014/feature/index.js';
import Level from '../../../../models/2014/level/index.js';
import Subclass from '../../../../models/2014/subclass/index.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import * as SubraceController from '../../../controllers/api/2014/subraceController.js';
import * as SubraceController from '../../../../controllers/api/2014/subraceController.js';

import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Proficiency from '../../../models/2014/proficiency/index.js';
import Subrace from '../../../models/2014/subrace/index.js';
import Trait from '../../../models/2014/trait/index.js';
import Proficiency from '../../../../models/2014/proficiency/index.js';
import Subrace from '../../../../models/2014/subrace/index.js';
import Trait from '../../../../models/2014/trait/index.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import Trait from '../../../models/2014/trait/index.js';
import TraitController from '../../../controllers/api/2014/traitController.js';
import Trait from '../../../../models/2014/trait/index.js';
import TraitController from '../../../../controllers/api/2014/traitController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mockingoose from 'mockingoose';
import { createRequest, createResponse } from 'node-mocks-http';
import { mockNext } from '../../support/requestHelpers.js';
import { mockNext } from '../../../support/requestHelpers.js';

import WeaponProperty from '../../../models/2014/weaponProperty/index.js';
import WeaponPropertyController from '../../../controllers/api/2014/weaponPropertyController.js';
import WeaponProperty from '../../../../models/2014/weaponProperty/index.js';
import WeaponPropertyController from '../../../../controllers/api/2014/weaponPropertyController.js';

beforeEach(() => {
mockingoose.resetAll();
Expand Down
Loading

0 comments on commit 501c8b7

Please sign in to comment.