Skip to content

Commit

Permalink
Merge pull request #2 from seatsio/configurable-cdn-url
Browse files Browse the repository at this point in the history
made seatsio cdn url configurable for test env purposes
  • Loading branch information
bverbeken authored Jan 11, 2019
2 parents f7d40d9 + 442ede2 commit 3c720df
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/main/Embeddable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class Embeddable extends React.Component {
let seatsio = await this.getSeatsio();
let {id, className, onRenderStarted, ...config} = this.props;
config.divId = this.props.id;
config.chartJsUrl = this.props.chartJsUrl;
let chart = this.createChart(seatsio, config).render();
this.chart = chart;
if (this.props.onRenderStarted) this.props.onRenderStarted(chart);
Expand All @@ -31,7 +32,7 @@ export default class Embeddable extends React.Component {
let script = document.createElement('script');
script.onload = () => resolve(seatsio);
script.onerror = () => reject(`Could not load ${script.src}`);
script.src = 'https://cdn.seatsio.net/chart.js';
script.src = this.props.chartJsUrl;
document.head.appendChild(script);
});
}
Expand All @@ -44,5 +45,6 @@ export default class Embeddable extends React.Component {
}

Embeddable.defaultProps = {
id: 'chart'
id: 'chart',
chartJsUrl: 'https://cdn.seatsio.net/chart.js'
};
12 changes: 7 additions & 5 deletions src/test/SeatsioDesigner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,30 @@ describe("SeatsioDesigner", () => {
};

it('renders the designer', () => {
let chart = mount((
let chart = mount(
<SeatsioDesigner/>
));
);

expect(chart.find('div#chart').length).toEqual(1);
});

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

Expand Down
4 changes: 3 additions & 1 deletion src/test/SeatsioEventManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ describe("SeatsioEventManager", () => {
id="someID"
className="someClassName"
publicKey="aPublicKey"
chartJsUrl="https://www.google.com"
onRenderStarted={chart => {
expect(chart.props).toEqual({
divId: 'someID',
publicKey: 'aPublicKey'
publicKey: 'aPublicKey',
chartJsUrl:"https://www.google.com"
});
resolve();
}}/>
Expand Down
19 changes: 18 additions & 1 deletion src/test/SeatsioSeatingChart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ describe("SeatsioSeatingChart", () => {
expect(chart.find('div#chart').length).toEqual(1);
});

it('renders the chart with default properties', () => {
return new Promise(resolve => {
mount((
<SeatsioSeatingChart
onRenderStarted={chart => {
expect(chart.props).toEqual({
divId: "chart",
chartJsUrl:"https://cdn.seatsio.net/chart.js"
});
resolve();
}}/>
));
});
});

it('renders the chart in a div with the specified ID', () => {
let chart = mount((
<SeatsioSeatingChart id="mySuperDuperChart"/>
Expand All @@ -57,10 +72,12 @@ describe("SeatsioSeatingChart", () => {
id="someID"
className="someClassName"
publicKey="aPublicKey"
chartJsUrl="https://www.google.com"
onRenderStarted={chart => {
expect(chart.props).toEqual({
divId: 'someID',
publicKey: 'aPublicKey'
publicKey: 'aPublicKey',
chartJsUrl:"https://www.google.com"
});
resolve();
}}/>
Expand Down

0 comments on commit 3c720df

Please sign in to comment.