Skip to content

Commit 02f6206

Browse files
committed
Fixing tests in several files
1 parent 225533e commit 02f6206

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { PlotlyBundleName } from 'dist/plotly/public-api';
2+
3+
import { PlotlyViaCDNModule } from './plotly-via-cdn.module';
4+
import { PlotlyService } from './plotly.service';
5+
6+
describe('PlotlyViaCDNModule', () => {
7+
let plotlyServiceCache: any = {};
8+
9+
beforeEach(() => {
10+
plotlyServiceCache.moduleName = (PlotlyService as any).moduleName;
11+
});
12+
13+
afterEach(() => {
14+
(PlotlyService as any).moduleName = plotlyServiceCache.moduleName;
15+
});
16+
17+
it('should create', () => {
18+
const plotlyService = jasmine.createSpyObj('PlotlyService', ['setModuleName']);
19+
const _ = new PlotlyViaCDNModule(plotlyService);
20+
21+
expect((PlotlyService as any).moduleName).toBe('ViaCDN');
22+
});
23+
24+
it('should set Plotly Bundle', () => {
25+
const validValues: any[] = ['basic', 'cartesian', 'geo', 'gl3d', 'gl2d', 'mapbox', 'finance', null];
26+
for (const value of validValues) {
27+
PlotlyViaCDNModule.setPlotlyBundle(value);
28+
expect((PlotlyViaCDNModule as any).plotlyBundle).toBe(value);
29+
}
30+
31+
const fn = () => (PlotlyViaCDNModule as any).setPlotlyBundle('Invalid name');
32+
const msg = `Invalid plotly bundle. Please set to null for full or "basic", "cartesian", "geo", "gl3d", "gl2d", "mapbox", "finance" for a partial bundle.`;
33+
expect(fn).toThrowError(msg);
34+
});
35+
36+
});

projects/plotly/src/lib/plotly-via-cdn.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class PlotlyViaCDNModule {
3333
PlotlyViaCDNModule.plotlyVersion = version;
3434
}
3535

36-
public static setPlotlyBundle(bundle: PlotlyBundleName): void {
36+
public static setPlotlyBundle(bundle: PlotlyBundleName | null): void {
3737
const isOk = bundle === null || PlotlyViaCDNModule.plotlyBundleNames.indexOf(bundle) >= 0;
3838
if (!isOk) {
3939
const names = PlotlyViaCDNModule.plotlyBundleNames.map(n => `"${n}"`).join(', ');

0 commit comments

Comments
 (0)