forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] Delete most uptime lodash references (#8)
* Delete most uptime lodash references. * Simplify. Clean up types.
- Loading branch information
1 parent
95665f0
commit 567f1e4
Showing
5 changed files
with
250 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
x-pack/plugins/uptime/server/lib/requests/search/__tests__/enrich_monitor_groups.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { sortChecksBy } from '../enrich_monitor_groups'; | ||
|
||
describe('enrich monitor groups', () => { | ||
describe('sortChecksBy', () => { | ||
it('identifies lesser geo name', () => { | ||
expect( | ||
sortChecksBy( | ||
{ observer: { geo: { name: 'less' } }, monitor: { status: 'up' } }, | ||
{ observer: { geo: { name: 'more' } }, monitor: { status: 'up' } } | ||
) | ||
).toBe(-1); | ||
}); | ||
|
||
it('identifies greater geo name', () => { | ||
expect( | ||
sortChecksBy( | ||
{ observer: { geo: { name: 'more' } }, monitor: { status: 'up' } }, | ||
{ observer: { geo: { name: 'less' } }, monitor: { status: 'up' } } | ||
) | ||
).toBe(1); | ||
}); | ||
|
||
it('identifies equivalent geo name and sorts by lesser ip', () => { | ||
expect( | ||
sortChecksBy( | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: '127.0.0.1', status: 'up' } }, | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: '127.0.0.2', status: 'up' } } | ||
) | ||
).toBe(-1); | ||
}); | ||
|
||
it('identifies equivalent geo name and sorts by greater ip', () => { | ||
expect( | ||
sortChecksBy( | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: '127.0.0.2', status: 'up' } }, | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: '127.0.0.1', status: 'up' } } | ||
) | ||
).toBe(1); | ||
}); | ||
|
||
it('identifies equivalent geo name and sorts by equivalent ip', () => { | ||
expect( | ||
sortChecksBy( | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: '127.0.0.1', status: 'up' } }, | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: '127.0.0.1', status: 'up' } } | ||
) | ||
).toBe(0); | ||
}); | ||
|
||
it('handles equivalent ip arrays', () => { | ||
expect( | ||
sortChecksBy( | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: ['127.0.0.1'], status: 'up' } }, | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: ['127.0.0.1'], status: 'up' } } | ||
) | ||
).toBe(0); | ||
}); | ||
|
||
it('handles non-equal ip arrays', () => { | ||
expect( | ||
sortChecksBy( | ||
{ | ||
observer: { geo: { name: 'same' } }, | ||
monitor: { ip: ['127.0.0.2', '127.0.0.9'], status: 'up' }, | ||
}, | ||
{ | ||
observer: { geo: { name: 'same' } }, | ||
monitor: { ip: ['127.0.0.3', '127.0.0.1'], status: 'up' }, | ||
} | ||
) | ||
).toBe(1); | ||
}); | ||
|
||
it('handles undefined observer fields', () => { | ||
expect( | ||
sortChecksBy( | ||
{ observer: undefined, monitor: { ip: ['127.0.0.1'], status: 'up' } }, | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: ['127.0.0.1'], status: 'up' } } | ||
) | ||
).toBe(-1); | ||
}); | ||
|
||
it('handles undefined ip fields', () => { | ||
expect( | ||
sortChecksBy( | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: undefined, status: 'up' } }, | ||
{ observer: { geo: { name: 'same' } }, monitor: { ip: ['127.0.0.1'], status: 'up' } } | ||
) | ||
).toBe(-1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters