|
6 | 6 |
|
7 | 7 | import { RequestTrialExtension } from '../public/sections/license_dashboard/request_trial_extension'; |
8 | 8 | import { createMockLicense, getComponent } from './util'; |
9 | | -const nonImminentExpirationTime = new Date().getTime() + (30 * 24 * 60 * 60 * 1000); |
10 | | -// ten days from now |
11 | | -const imminentExpirationTime = new Date().getTime() + (10 * 24 * 60 * 60 * 1000); |
12 | 9 |
|
13 | 10 | describe('RequestTrialExtension component', () => { |
14 | | - test('should not display when trial expires in > 24 days', () => { |
| 11 | + test('should not display when license is active and trial has not been used', () => { |
15 | 12 | const rendered = getComponent( |
16 | 13 | { |
17 | | - license: createMockLicense('trial', nonImminentExpirationTime) |
| 14 | + trialStatus: { |
| 15 | + canStartTrial: true |
| 16 | + }, |
| 17 | + license: createMockLicense('trial') |
18 | 18 | }, |
19 | 19 | RequestTrialExtension |
20 | 20 | ); |
21 | 21 | const html = rendered.html(); |
22 | 22 | expect(html).toBeNull(); |
23 | 23 | }); |
24 | | - test('should display when trial license is expired', () => { |
| 24 | + test('should display when license is active and trial has been used', () => { |
25 | 25 | const rendered = getComponent( |
26 | 26 | { |
27 | | - license: createMockLicense('trial', 0) |
| 27 | + trialStatus: { |
| 28 | + canStartTrial: false |
| 29 | + }, |
| 30 | + license: createMockLicense('trial') |
28 | 31 | }, |
29 | 32 | RequestTrialExtension |
30 | 33 | ); |
31 | 34 | const html = rendered.html(); |
32 | 35 | expect(html).not.toBeNull(); |
33 | 36 | expect(html).toMatchSnapshot(); |
34 | 37 | }); |
35 | | - test('should display when trial license is about to expire', () => { |
| 38 | + test('should not display when license is not active and trial has not been used', () => { |
36 | 39 | const rendered = getComponent( |
37 | 40 | { |
38 | | - license: createMockLicense('trial', imminentExpirationTime) |
| 41 | + trialStatus: { |
| 42 | + canStartTrial: true |
| 43 | + }, |
| 44 | + license: createMockLicense('trial', 0) |
39 | 45 | }, |
40 | 46 | RequestTrialExtension |
41 | 47 | ); |
42 | 48 | const html = rendered.html(); |
43 | | - expect(html).not.toBeNull(); |
44 | | - expect(html).toMatchSnapshot(); |
45 | | - }); |
46 | | - test('should not display for about to expire basic license', () => { |
47 | | - const rendered = getComponent( |
48 | | - { |
49 | | - license: createMockLicense('basic', imminentExpirationTime) |
50 | | - }, |
51 | | - RequestTrialExtension |
52 | | - ); |
53 | | - expect(rendered.html()).toBeNull(); |
54 | | - }); |
55 | | - test('should not display for expired basic license', () => { |
56 | | - const rendered = getComponent( |
57 | | - { |
58 | | - license: createMockLicense('basic', 0) |
59 | | - }, |
60 | | - RequestTrialExtension |
61 | | - ); |
62 | | - expect(rendered.html()).toBeNull(); |
63 | | - }); |
64 | | - test('should not display for active basic license', () => { |
65 | | - const rendered = getComponent( |
66 | | - { |
67 | | - license: createMockLicense('basic') |
68 | | - }, |
69 | | - RequestTrialExtension |
70 | | - ); |
71 | | - expect(rendered.html()).toBeNull(); |
72 | | - }); |
73 | | - test('should not display for about to expire gold license', () => { |
74 | | - const rendered = getComponent( |
75 | | - { |
76 | | - license: createMockLicense('gold', imminentExpirationTime) |
77 | | - }, |
78 | | - RequestTrialExtension |
79 | | - ); |
80 | | - expect(rendered.html()).toBeNull(); |
81 | | - }); |
82 | | - test('should not display for expired gold license', () => { |
83 | | - const rendered = getComponent( |
84 | | - { |
85 | | - license: createMockLicense('gold', 0) |
86 | | - }, |
87 | | - RequestTrialExtension |
88 | | - ); |
89 | | - expect(rendered.html()).toBeNull(); |
90 | | - }); |
91 | | - test('should not display for active gold license', () => { |
92 | | - const rendered = getComponent( |
93 | | - { |
94 | | - license: createMockLicense('gold') |
95 | | - }, |
96 | | - RequestTrialExtension |
97 | | - ); |
98 | | - expect(rendered.html()).toBeNull(); |
| 49 | + expect(html).toBeNull(); |
99 | 50 | }); |
100 | | - test('should not display for about to expire platinum license', () => { |
| 51 | + test('should display when license is not active and trial has been used', () => { |
101 | 52 | const rendered = getComponent( |
102 | 53 | { |
103 | | - license: createMockLicense('platinum', imminentExpirationTime) |
| 54 | + trialStatus: { |
| 55 | + canStartTrial: false |
| 56 | + }, |
| 57 | + license: createMockLicense('trial', 0) |
104 | 58 | }, |
105 | 59 | RequestTrialExtension |
106 | 60 | ); |
107 | | - expect(rendered.html()).toBeNull(); |
| 61 | + const html = rendered.html(); |
| 62 | + expect(html).not.toBeNull(); |
| 63 | + expect(html).toMatchSnapshot(); |
108 | 64 | }); |
109 | | - test('should not display for expired platinum license', () => { |
| 65 | + test('should display when platinum license is not active and trial has been used', () => { |
110 | 66 | const rendered = getComponent( |
111 | 67 | { |
| 68 | + trialStatus: { |
| 69 | + canStartTrial: false |
| 70 | + }, |
112 | 71 | license: createMockLicense('platinum', 0) |
113 | 72 | }, |
114 | 73 | RequestTrialExtension |
115 | 74 | ); |
116 | | - expect(rendered.html()).toBeNull(); |
| 75 | + const html = rendered.html(); |
| 76 | + expect(html).not.toBeNull(); |
| 77 | + expect(html).toMatchSnapshot(); |
117 | 78 | }); |
118 | | - test('should not display for active platinum license', () => { |
| 79 | + test('should not display when platinum license is active and trial has been used', () => { |
119 | 80 | const rendered = getComponent( |
120 | 81 | { |
| 82 | + trialStatus: { |
| 83 | + canStartTrial: false |
| 84 | + }, |
121 | 85 | license: createMockLicense('platinum') |
122 | 86 | }, |
123 | 87 | RequestTrialExtension |
124 | 88 | ); |
125 | | - expect(rendered.html()).toBeNull(); |
| 89 | + const html = rendered.html(); |
| 90 | + expect(html).toBeNull(); |
126 | 91 | }); |
127 | 92 | }); |
0 commit comments