|
1 | | -import { |
2 | | - RedisCloudSubscription, |
3 | | - RedisCloudSubscriptionStatus, |
4 | | -} from 'uiSrc/slices/interfaces' |
| 1 | +import { RedisCloudSubscriptionStatus } from 'uiSrc/slices/interfaces' |
5 | 2 | import { canSelectRow } from './canSelectRow' |
| 3 | +import { RedisCloudSubscriptionFactory } from 'uiSrc/mocks/factories/cloud/RedisCloudSubscription.factory' |
6 | 4 |
|
7 | 5 | describe('canSelectRow', () => { |
8 | 6 | it('should return true when subscription is active and has databases', () => { |
9 | 7 | const row = { |
10 | | - original: { |
11 | | - id: 1, |
| 8 | + original: RedisCloudSubscriptionFactory.build({ |
12 | 9 | status: RedisCloudSubscriptionStatus.Active, |
13 | 10 | numberOfDatabases: 5, |
14 | | - } as RedisCloudSubscription, |
15 | | - } as any |
| 11 | + }), |
| 12 | + } |
16 | 13 |
|
17 | 14 | expect(canSelectRow(row)).toBe(true) |
18 | 15 | }) |
19 | 16 |
|
20 | 17 | it('should return false when subscription is not active', () => { |
21 | 18 | const row = { |
22 | | - original: { |
23 | | - id: 1, |
| 19 | + original: RedisCloudSubscriptionFactory.build({ |
24 | 20 | status: RedisCloudSubscriptionStatus.Deleting, |
25 | 21 | numberOfDatabases: 5, |
26 | | - } as RedisCloudSubscription, |
27 | | - } as any |
| 22 | + }), |
| 23 | + } |
28 | 24 |
|
29 | 25 | expect(canSelectRow(row)).toBe(false) |
30 | 26 | }) |
31 | 27 |
|
32 | 28 | it('should return false when subscription has no databases', () => { |
33 | 29 | const row = { |
34 | | - original: { |
35 | | - id: 1, |
| 30 | + original: RedisCloudSubscriptionFactory.build({ |
36 | 31 | status: RedisCloudSubscriptionStatus.Active, |
37 | 32 | numberOfDatabases: 0, |
38 | | - } as RedisCloudSubscription, |
| 33 | + }), |
39 | 34 | } as any |
40 | 35 |
|
41 | 36 | expect(canSelectRow(row)).toBe(false) |
42 | 37 | }) |
43 | 38 |
|
44 | 39 | it('should return false when subscription is not active and has no databases', () => { |
45 | 40 | const row = { |
46 | | - original: { |
47 | | - id: 1, |
| 41 | + original: RedisCloudSubscriptionFactory.build({ |
48 | 42 | status: RedisCloudSubscriptionStatus.Error, |
49 | 43 | numberOfDatabases: 0, |
50 | | - } as RedisCloudSubscription, |
51 | | - } as any |
| 44 | + }), |
| 45 | + } |
52 | 46 |
|
53 | 47 | expect(canSelectRow(row)).toBe(false) |
54 | 48 | }) |
|
0 commit comments