Add build pipeline tests for undefined data. (#42080) (#42284)

This commit is contained in:
Luke Elmers 2019-07-30 14:02:41 -06:00 committed by GitHub
parent 4e1d8d2871
commit 0b3c817f69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -40,6 +40,11 @@ describe('visualize loader pipeline helpers: build pipeline', () => {
const actual = prepareJson('foo', { well: `hello 'hi'`, there: { friend: true } });
expect(actual).toBe(expected);
});
it('returns empty string if data is undefined', () => {
const actual = prepareJson('foo', undefined);
expect(actual).toBe('');
});
});
describe('prepareString', () => {
@ -54,6 +59,11 @@ describe('visualize loader pipeline helpers: build pipeline', () => {
const actual = prepareString('foo', `'bar'`);
expect(actual).toBe(expected);
});
it('returns empty string if data is undefined', () => {
const actual = prepareString('foo', undefined);
expect(actual).toBe('');
});
});
describe('buildPipelineVisFunction', () => {

View file

@ -192,7 +192,7 @@ export const getSchemas = (vis: Vis, timeRange?: any): Schemas => {
return schemas;
};
export const prepareJson = (variable: string, data: object): string => {
export const prepareJson = (variable: string, data?: object): string => {
if (data === undefined) {
return '';
}