Skip to content

Commit

Permalink
Merge pull request #3 from seatsio/bugfix-chartjsurl
Browse files Browse the repository at this point in the history
don't pass chartJsUrl to the designer/renderer/EM config
  • Loading branch information
bverbeken authored Jan 24, 2019
2 parents e21c567 + 98cdc62 commit 3e874ed
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 10 deletions.
17 changes: 12 additions & 5 deletions src/main/Embeddable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import React from 'react';
export default class Embeddable extends React.Component {

async componentDidMount() {
let seatsio = await this.getSeatsio();
let {id, className, onRenderStarted, ...config} = this.props;
const seatsio = await this.getSeatsio();
const config = this.extractConfigFromProps();
config.divId = this.props.id;
config.chartJsUrl = this.props.chartJsUrl;
let chart = this.createChart(seatsio, config).render();
const chart = this.createChart(seatsio, config).render();
this.chart = chart;
if (this.props.onRenderStarted) this.props.onRenderStarted(chart);
if (this.props.onRenderStarted) {
this.props.onRenderStarted(chart);
}
}

extractConfigFromProps() {
// noinspection JSUnusedLocalSymbols
let {id, className, onRenderStarted, chartJsUrl, ...config} = this.props;
return config;
}

componentWillUnmount() {
Expand Down
20 changes: 19 additions & 1 deletion src/test/SeatsioDesigner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ describe("SeatsioDesigner", () => {
});

it('passes parameters onto the designer', () => {
return new Promise(resolve => {
mount(
<SeatsioDesigner
id="someID"
className="someClassName"
designerKey="aDesignerKey"
onRenderStarted={chart => {
expect(chart.props).toEqual({
divId: 'someID',
designerKey: 'aDesignerKey',
});
resolve();
}}/>
);
});
});


it('does not pass chartJsUrl onto the designer', () => {
return new Promise(resolve => {
mount(
<SeatsioDesigner
Expand All @@ -46,7 +65,6 @@ describe("SeatsioDesigner", () => {
expect(chart.props).toEqual({
divId: 'someID',
designerKey: 'aDesignerKey',
chartJsUrl: 'https://www.google.com'
});
resolve();
}}/>
Expand Down
19 changes: 18 additions & 1 deletion src/test/SeatsioEventManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ describe("SeatsioEventManager", () => {
});

it('passes parameters onto the event manager', () => {
return new Promise(resolve => {
mount((
<SeatsioEventManager
id="someID"
className="someClassName"
publicKey="aPublicKey"
onRenderStarted={chart => {
expect(chart.props).toEqual({
divId: 'someID',
publicKey: 'aPublicKey',
});
resolve();
}}/>
));
});
});

it('does not pass chartJsUrl onto the event manager', () => {
return new Promise(resolve => {
mount((
<SeatsioEventManager
Expand All @@ -46,7 +64,6 @@ describe("SeatsioEventManager", () => {
expect(chart.props).toEqual({
divId: 'someID',
publicKey: 'aPublicKey',
chartJsUrl:"https://www.google.com"
});
resolve();
}}/>
Expand Down
22 changes: 19 additions & 3 deletions src/test/SeatsioSeatingChart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ describe("SeatsioSeatingChart", () => {
<SeatsioSeatingChart
onRenderStarted={chart => {
expect(chart.props).toEqual({
divId: "chart",
chartJsUrl:"https://cdn.seatsio.net/chart.js"
divId: "chart"
});
resolve();
}}/>
Expand All @@ -66,6 +65,24 @@ describe("SeatsioSeatingChart", () => {
});

it('passes parameters onto the chart', () => {
return new Promise(resolve => {
mount((
<SeatsioSeatingChart
id="someID"
className="someClassName"
publicKey="aPublicKey"
onRenderStarted={chart => {
expect(chart.props).toEqual({
divId: 'someID',
publicKey: 'aPublicKey',
});
resolve();
}}/>
));
});
});

it('does not pass chartJsUrl onto the chart', () => {
return new Promise(resolve => {
mount((
<SeatsioSeatingChart
Expand All @@ -77,7 +94,6 @@ describe("SeatsioSeatingChart", () => {
expect(chart.props).toEqual({
divId: 'someID',
publicKey: 'aPublicKey',
chartJsUrl:"https://www.google.com"
});
resolve();
}}/>
Expand Down

0 comments on commit 3e874ed

Please sign in to comment.