Skip to content

Commit

Permalink
Update tests that reference update config/server data
Browse files Browse the repository at this point in the history
  • Loading branch information
matschaffer committed Feb 15, 2022
1 parent 36d0b46 commit 5064cbc
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,9 @@ jest.mock('../../static_globals', () => ({
}));

function getMockReq(metricsBuckets = []) {
const config = {
get: sinon.stub(),
};

config.get.withArgs('monitoring.ui.min_interval_seconds').returns(10);

return {
server: {
config() {
return config;
},
config: { ui: { min_interval_seconds: 10 } },
plugins: {
elasticsearch: {
getCluster: sinon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ jest.mock('../../../details/get_metrics', () => ({
describe('getPaginatedNodes', () => {
const req = {
server: {
config: () => ({
get: () => 10,
}),
config: { ui: { max_bucket_size: 10000 } },
},
};
const clusterUuid = '1abc';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ describe('getIndicesUnassignedShardStats', () => {
const req = {
payload: {},
server: {
config: () => ({
get: () => {},
}),
config: { ui: { max_bucket_size: 10000 } },
plugins: {
elasticsearch: {
getCluster: () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ describe('getNodeShardCount', () => {
const req = {
payload: {},
server: {
config: () => ({
get: () => {},
}),
config: { ui: { max_bucket_size: 10000 } },
plugins: {
elasticsearch: {
getCluster: () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@ jest.mock('../../static_globals', () => ({

describe('getNodes', () => {
it('ensures collapse key is present query responses', async () => {
const configs: { [key: string]: number } = { 'monitoring.ui.max_bucket_size': 10000 };
const config = {
get: jest.fn().mockImplementation((key: string) => configs[key]),
};

const response = {};
const callWithRequest = jest.fn().mockResolvedValue(response);

const req = {
server: {
config() {
return config;
},
config: { ui: { max_bucket_size: 10000 } },
plugins: {
elasticsearch: {
getCluster: () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const mockReq = (
) => {
return {
server: {
instanceUuid: 'kibana-1234',
newPlatform: {
setup: {
plugins: {
Expand All @@ -28,15 +29,7 @@ const mockReq = (
},
},
},
config() {
return {
get: jest.fn((prop) => {
if (prop === 'server.uuid') {
return 'kibana-1234';
}
}),
};
},
config: { ui: { ccs: { enabled: false } } },
usage: {
collectorSet: {
getCollectorByType: () => ({
Expand Down

0 comments on commit 5064cbc

Please sign in to comment.