Skip to content

Commit

Permalink
Fix tests after uisettings was added
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed May 26, 2023
1 parent ca3db4d commit c33fcb5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ jest.mock('src/plugins/vis_augmenter/public/view_events_flyout/flyout_state', ()
};
});

// Mocking the UISettings service. This is needed when making eligibility checks for the actions,
// which does UISettings checks to ensure the feature is enabled.
jest.mock('src/plugins/vis_augmenter/public/services.ts', () => {
return {
getUISettings: () => {
return {
get: (config: string) => {
switch (config) {
case 'visualization:enablePluginAugmentation':
return true;
case 'visualization:enablePluginAugmentation.maxPluginObjects':
return 10;
default:
throw new Error(`Accessing ${config} is not supported in the mock.`);
}
},
};
},
};
});

let coreStart: CoreStart;

beforeEach(async () => {
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/vis_type_vega/public/expressions/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ describe('helpers', function () {

describe('setupConfig()', function () {
it('check all legend positions', function () {
const visAugmenterConfig = {
some: 'config',
};
const baseConfig = {
view: {
stroke: null,
Expand All @@ -59,13 +62,15 @@ describe('helpers', function () {
},
kibana: {
hideWarnings: true,
visAugmenterConfig,
},
};
const positions = ['top', 'right', 'left', 'bottom'];
positions.forEach((position) => {
const visParams = { legendPosition: position };
baseConfig.legend.orient = position;
expect(setupConfig(visParams)).toStrictEqual(baseConfig);
baseConfig.legend.offset = position === 'top' || position === 'bottom' ? 0 : 18;
expect(setupConfig(visParams, visAugmenterConfig)).toStrictEqual(baseConfig);
});
});
});
Expand Down

0 comments on commit c33fcb5

Please sign in to comment.