|
| 1 | +import {prepareClusterCoresLink, prepareClusterLoggingLinks} from '../useClusterLinks'; |
| 2 | + |
| 3 | +describe('prepareClusterCoresLink', () => { |
| 4 | + it('It should parse stringified json with cores url', () => { |
| 5 | + expect( |
| 6 | + prepareClusterCoresLink('{"url":"https://coredumps.com?cluster=my_cluster"}'), |
| 7 | + ).toEqual('https://coredumps.com?cluster=my_cluster'); |
| 8 | + }); |
| 9 | + |
| 10 | + it('It should return undefined if input is undefined', () => { |
| 11 | + expect(prepareClusterCoresLink(undefined)).toEqual(undefined); |
| 12 | + }); |
| 13 | + it('It should return undefined if input is incorrect', () => { |
| 14 | + expect(prepareClusterCoresLink('hello')).toEqual(undefined); |
| 15 | + }); |
| 16 | +}); |
| 17 | + |
| 18 | +describe('prepareClusterLoggingLinks', () => { |
| 19 | + it('It should parse stringified json with logging and slo logs urls', () => { |
| 20 | + expect( |
| 21 | + prepareClusterLoggingLinks( |
| 22 | + '{"url":"https://logging.com/logs?cluster=my_cluster","slo_logs_url":"https://logging.com/slo-logs?cluster=my_cluster"}', |
| 23 | + ), |
| 24 | + ).toEqual({ |
| 25 | + logsUrl: 'https://logging.com/logs?cluster=my_cluster', |
| 26 | + sloLogsUrl: 'https://logging.com/slo-logs?cluster=my_cluster', |
| 27 | + }); |
| 28 | + }); |
| 29 | + it('It should parse stringified json with only logging url', () => { |
| 30 | + expect( |
| 31 | + prepareClusterLoggingLinks('{"url":"https://logging.com/logs?cluster=my_cluster"}'), |
| 32 | + ).toEqual({ |
| 33 | + logsUrl: 'https://logging.com/logs?cluster=my_cluster', |
| 34 | + }); |
| 35 | + }); |
| 36 | + it('It should parse stringified json with only slo logs url', () => { |
| 37 | + expect( |
| 38 | + prepareClusterLoggingLinks( |
| 39 | + '{"slo_logs_url":"https://logging.com/slo-logs?cluster=my_cluster"}', |
| 40 | + ), |
| 41 | + ).toEqual({ |
| 42 | + sloLogsUrl: 'https://logging.com/slo-logs?cluster=my_cluster', |
| 43 | + }); |
| 44 | + }); |
| 45 | + it('It should return empty object if input is undefined', () => { |
| 46 | + expect(prepareClusterLoggingLinks(undefined)).toEqual({}); |
| 47 | + }); |
| 48 | + it('It should return empty object if input is incorrect', () => { |
| 49 | + expect(prepareClusterLoggingLinks('hello')).toEqual({}); |
| 50 | + }); |
| 51 | +}); |
0 commit comments