Skip to content

Commit

Permalink
Bufix: pass settings to from Radix to AspectCalculator (#71)
Browse files Browse the repository at this point in the history
* Test to drive bugfix: #71

* Bufix: pass settings to from Radix to AspectCalculator

---------

Co-authored-by: CI Bot <[email protected]>
  • Loading branch information
harlantwood and CI Bot authored Mar 21, 2024
1 parent a16fb94 commit 72d8018
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"types": "./dist/project/src/index.d.ts",
"scripts": {
"test": "jest",
"test:w": "jest --watch",
"test:coverage": "jest --coverage",
"build": "webpack",
"build:w": "webpack --watch",
Expand Down
42 changes: 42 additions & 0 deletions project/src/radix.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Radix from './radix';
import SVG from './svg';
import default_settings from './settings';

describe('Radix', () => {
const data = {
planets: {
Sun: [0],
Moon: [90],
},
cusps: [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330]
};

it('should draw aspect lines with default colors', () => {
document.body.innerHTML = '<div id="chart"></div>';
const settings = default_settings;
const paper = new SVG('chart', 500, 500, settings);
const radix = new Radix(paper, 500, 500, 500, data, settings);
radix.aspects();

const aspectLines = document.querySelectorAll('#chart-astrology-aspects > line');
expect(aspectLines[0].getAttribute('stroke')).toBe(default_settings.ASPECTS.square.color);
});

it('should draw aspect lines with custom colors via settings', () => {
document.body.innerHTML = '<div id="chart"></div>';

const settings = {
...default_settings,
ASPECTS: {
square: { degree: 90, orbit: 10, color: 'purple' },
},
};

const paper = new SVG('chart', 500, 500, settings);
const radix = new Radix(paper, 500, 500, 500, data, settings);
radix.aspects();

const aspectLines = document.querySelectorAll('#chart-astrology-aspects > line');
expect(aspectLines[0].getAttribute('stroke')).toBe('purple');
});
});
2 changes: 1 addition & 1 deletion project/src/radix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class Radix {
aspects(customAspects?: FormedAspect[] | null): Radix {
const aspectsList = customAspects != null && Array.isArray(customAspects)
? customAspects
: new AspectCalculator(this.toPoints).radix(this.data.planets)
: new AspectCalculator(this.toPoints, this.settings).radix(this.data.planets)

const universe = this.universe
const wrapper = getEmptyWrapper(universe, this.paper.root.id + '-' + this.settings.ID_ASPECTS, this.paper.root.id)
Expand Down

0 comments on commit 72d8018

Please sign in to comment.