Browse Source

test(targets): cover preset totals and editable copies

pull/8458/head
PJ 4 days ago
parent
commit
af63e9246b
  1. 35
      libs/common/src/lib/portfolio-targets/portfolio-targets-presets.spec.ts

35
libs/common/src/lib/portfolio-targets/portfolio-targets-presets.spec.ts

@ -0,0 +1,35 @@
import { AssetClass } from '@ghostfolio/prisma/enums';
import {
createDefaultPortfolioTarget,
PORTFOLIO_TARGET_PRESETS
} from './portfolio-targets-presets';
import { isValidPortfolioTarget } from './portfolio-targets-calculator';
describe('Portfolio target presets', () => {
it('provides five valid, editable starting points', () => {
expect(PORTFOLIO_TARGET_PRESETS).toHaveLength(5);
for (const { allocations } of PORTFOLIO_TARGET_PRESETS) {
expect(isValidPortfolioTarget(allocations, 0.05)).toBe(true);
}
});
it('keeps the original global default independent from the presets', () => {
const target = createDefaultPortfolioTarget();
target.allocations[AssetClass.EQUITY] = 0.1;
expect(PORTFOLIO_TARGET_PRESETS[2].allocations[AssetClass.EQUITY]).toBe(0.6);
expect(target.tolerance).toBe(0.05);
expect(target.id).toBe('global');
});
it('represents Golden Butterfly at macro-class level', () => {
const butterfly = PORTFOLIO_TARGET_PRESETS.find(
({ id }) => id === 'golden-butterfly'
);
expect(butterfly?.allocations[AssetClass.EQUITY]).toBe(0.4);
expect(butterfly?.allocations[AssetClass.FIXED_INCOME]).toBe(0.4);
expect(butterfly?.allocations[AssetClass.COMMODITY]).toBe(0.2);
});
});
Loading…
Cancel
Save