|
2 | 2 | handleUpdateLogic, |
3 | 3 | isK8sNameDescriptionDataValid, |
4 | 4 | LimitNameResourceType, |
| 5 | + resourceTypeLimits, |
5 | 6 | setupDefaults, |
6 | 7 | } from '~/concepts/k8s/K8sNameDescriptionField/utils'; |
7 | 8 | import { K8sNameDescriptionFieldData } from '~/concepts/k8s/K8sNameDescriptionField/types'; |
@@ -74,6 +75,81 @@ describe('setupDefaults', () => { |
74 | 75 | }), |
75 | 76 | ); |
76 | 77 | }); |
| 78 | + |
| 79 | + it('should limit PVC resource name', () => { |
| 80 | + expect( |
| 81 | + setupDefaults({ |
| 82 | + initialData: mockProjectK8sResource({ |
| 83 | + displayName: |
| 84 | + 'this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test ', |
| 85 | + k8sName: '', |
| 86 | + description: 'my description', |
| 87 | + }), |
| 88 | + limitNameResourceType: LimitNameResourceType.PVC, |
| 89 | + }), |
| 90 | + ).toEqual( |
| 91 | + mockK8sNameDescriptionFieldData({ |
| 92 | + name: 'this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test ', |
| 93 | + description: 'my description', |
| 94 | + k8sName: { |
| 95 | + value: 'this-is-a-test-this-is-a-test-this-is-a-test-this-is-a-test-thi', |
| 96 | + state: { |
| 97 | + immutable: false, |
| 98 | + maxLength: resourceTypeLimits[LimitNameResourceType.PVC], |
| 99 | + }, |
| 100 | + }, |
| 101 | + }), |
| 102 | + ); |
| 103 | + }); |
| 104 | + |
| 105 | + it('should limit project/workbench resource name', () => { |
| 106 | + expect( |
| 107 | + setupDefaults({ |
| 108 | + initialData: mockProjectK8sResource({ |
| 109 | + displayName: |
| 110 | + 'this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test ', |
| 111 | + k8sName: '', |
| 112 | + description: 'my description', |
| 113 | + }), |
| 114 | + limitNameResourceType: LimitNameResourceType.PROJECT, |
| 115 | + }), |
| 116 | + ).toEqual( |
| 117 | + mockK8sNameDescriptionFieldData({ |
| 118 | + name: 'this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test ', |
| 119 | + description: 'my description', |
| 120 | + k8sName: { |
| 121 | + value: 'this-is-a-test-this-is-a-test', |
| 122 | + state: { |
| 123 | + immutable: false, |
| 124 | + maxLength: resourceTypeLimits[LimitNameResourceType.PROJECT], |
| 125 | + }, |
| 126 | + }, |
| 127 | + }), |
| 128 | + ); |
| 129 | + expect( |
| 130 | + setupDefaults({ |
| 131 | + initialData: mockProjectK8sResource({ |
| 132 | + displayName: |
| 133 | + 'this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test ', |
| 134 | + k8sName: '', |
| 135 | + description: 'my description', |
| 136 | + }), |
| 137 | + limitNameResourceType: LimitNameResourceType.WORKBENCH, |
| 138 | + }), |
| 139 | + ).toEqual( |
| 140 | + mockK8sNameDescriptionFieldData({ |
| 141 | + name: 'this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test this is a test ', |
| 142 | + description: 'my description', |
| 143 | + k8sName: { |
| 144 | + value: 'this-is-a-test-this-is-a-test', |
| 145 | + state: { |
| 146 | + immutable: false, |
| 147 | + maxLength: resourceTypeLimits[LimitNameResourceType.WORKBENCH], |
| 148 | + }, |
| 149 | + }, |
| 150 | + }), |
| 151 | + ); |
| 152 | + }); |
77 | 153 | }); |
78 | 154 |
|
79 | 155 | describe('handleUpdateLogic', () => { |
|
0 commit comments