|
| 1 | +import {isOrgIOx} from 'src/organizations/selectors' |
| 2 | + |
| 3 | +let fakeState: any = {} |
| 4 | + |
| 5 | +describe('determining if an org is an IOx org', () => { |
| 6 | + beforeEach(() => { |
| 7 | + fakeState = { |
| 8 | + resources: { |
| 9 | + orgs: { |
| 10 | + byID: { |
| 11 | + '9c5955fc99a60b8f': { |
| 12 | + links: { |
| 13 | + buckets: '/api/v2/buckets?org=dev', |
| 14 | + dashboards: '/api/v2/dashboards?org=dev', |
| 15 | + labels: '/api/v2/orgs/9c5955fc99a60b8f/labels', |
| 16 | + limits: '/api/v2/orgs/9c5955fc99a60b8f/limits', |
| 17 | + logs: '/api/v2/orgs/9c5955fc99a60b8f/logs', |
| 18 | + members: '/api/v2/orgs/9c5955fc99a60b8f/members', |
| 19 | + owners: '/api/v2/orgs/9c5955fc99a60b8f/owners', |
| 20 | + secrets: '/api/v2/orgs/9c5955fc99a60b8f/secrets', |
| 21 | + self: '/api/v2/orgs/9c5955fc99a60b8f', |
| 22 | + tasks: '/api/v2/tasks?org=dev', |
| 23 | + }, |
| 24 | + id: '9c5955fc99a60b8f', |
| 25 | + name: 'dev', |
| 26 | + description: '', |
| 27 | + defaultStorageType: 'tsm', |
| 28 | + createdAt: '2022-10-24T17:06:47.427700345Z', |
| 29 | + updatedAt: '2022-10-24T17:06:47.427700533Z', |
| 30 | + }, |
| 31 | + }, |
| 32 | + allIDs: ['9c5955fc99a60b8f'], |
| 33 | + status: 'Done', |
| 34 | + org: { |
| 35 | + links: { |
| 36 | + buckets: '/api/v2/buckets?org=dev', |
| 37 | + dashboards: '/api/v2/dashboards?org=dev', |
| 38 | + labels: '/api/v2/orgs/9c5955fc99a60b8f/labels', |
| 39 | + limits: '/api/v2/orgs/9c5955fc99a60b8f/limits', |
| 40 | + logs: '/api/v2/orgs/9c5955fc99a60b8f/logs', |
| 41 | + members: '/api/v2/orgs/9c5955fc99a60b8f/members', |
| 42 | + owners: '/api/v2/orgs/9c5955fc99a60b8f/owners', |
| 43 | + secrets: '/api/v2/orgs/9c5955fc99a60b8f/secrets', |
| 44 | + self: '/api/v2/orgs/9c5955fc99a60b8f', |
| 45 | + tasks: '/api/v2/tasks?org=dev', |
| 46 | + }, |
| 47 | + id: '9c5955fc99a60b8f', |
| 48 | + name: 'dev', |
| 49 | + description: '', |
| 50 | + defaultStorageType: 'tsm', |
| 51 | + createdAt: '2022-10-24T17:06:47.427700345Z', |
| 52 | + updatedAt: '2022-10-24T17:06:47.427700533Z', |
| 53 | + }, |
| 54 | + }, |
| 55 | + }, |
| 56 | + } |
| 57 | + }) |
| 58 | + it('returns false when the defaultStorageType is tsm', () => { |
| 59 | + expect(isOrgIOx(fakeState)).toBe(false) |
| 60 | + }) |
| 61 | + |
| 62 | + it('returns false when the defaultStorageType is an empty string', () => { |
| 63 | + fakeState.resources.orgs.org.defaultStorageType = '' |
| 64 | + expect(isOrgIOx(fakeState)).toBe(false) |
| 65 | + }) |
| 66 | + |
| 67 | + it('returns false when the defaultStorageType is null', () => { |
| 68 | + fakeState.resources.orgs.org.defaultStorageType = null |
| 69 | + expect(isOrgIOx(fakeState)).toBe(false) |
| 70 | + }) |
| 71 | + |
| 72 | + it('returns false when no storage type is present', () => { |
| 73 | + delete fakeState.resources.orgs.org.defaultStorageType |
| 74 | + expect(isOrgIOx(fakeState)).toBe(false) |
| 75 | + }) |
| 76 | + |
| 77 | + it('returns true when the defaultStorageType is iox', () => { |
| 78 | + fakeState.resources.orgs.org.defaultStorageType = 'iox' |
| 79 | + expect(isOrgIOx(fakeState)).toBe(true) |
| 80 | + |
| 81 | + fakeState.resources.orgs.org.defaultStorageType = 'IoX' |
| 82 | + expect(isOrgIOx(fakeState)).toBe(true) |
| 83 | + }) |
| 84 | +}) |
0 commit comments