Skip to content

Commit 511b80c

Browse files
Lindsay-00Lingxi Chen
andauthored
Version decouple unit test (#363)
* added version decoupling for wlm dashboard Signed-off-by: Lingxi Chen <[email protected]> * fix lint Signed-off-by: Lingxi Chen <[email protected]> * added uts Signed-off-by: Lingxi Chen <[email protected]> * fix lint Signed-off-by: Lingxi Chen <[email protected]> --------- Signed-off-by: Lingxi Chen <[email protected]> Co-authored-by: Lingxi Chen <[email protected]>
1 parent c383ebb commit 511b80c

File tree

1 file changed

+95
-1
lines changed

1 file changed

+95
-1
lines changed

public/utils/datasource-utils.test.ts

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
* permissions and limitations under the License.
1919
*/
2020

21-
import { getDataSourceFromUrl, isDataSourceCompatible } from './datasource-utils';
21+
import {
22+
getDataSourceFromUrl,
23+
isDataSourceCompatible,
24+
isWLMDataSourceCompatible,
25+
} from './datasource-utils';
2226

2327
describe('Tests datasource utils', () => {
2428
it('Tests getting the datasource from the url', () => {
@@ -167,4 +171,94 @@ describe('Tests datasource utils', () => {
167171
).toBe(false);
168172
});
169173
});
174+
175+
describe('isWLMDataSourceCompatible', () => {
176+
it('returns true for versions >= 3.1.0', () => {
177+
expect(
178+
isWLMDataSourceCompatible({
179+
attributes: {
180+
dataSourceVersion: '3.1.0',
181+
title: '',
182+
endpoint: '',
183+
auth: { type: '', credentials: undefined },
184+
},
185+
id: '',
186+
type: '',
187+
references: [],
188+
} as any)
189+
).toBe(true);
190+
191+
expect(
192+
isWLMDataSourceCompatible({
193+
attributes: {
194+
dataSourceVersion: '3.3.0',
195+
title: '',
196+
endpoint: '',
197+
auth: { type: '', credentials: undefined },
198+
},
199+
id: '',
200+
type: '',
201+
references: [],
202+
} as any)
203+
).toBe(true);
204+
});
205+
206+
it('returns false for versions < 3.1.0 or invalid/pre-release', () => {
207+
expect(
208+
isWLMDataSourceCompatible({
209+
attributes: {
210+
dataSourceVersion: '3.0.0',
211+
title: '',
212+
endpoint: '',
213+
auth: { type: '', credentials: undefined },
214+
},
215+
id: '',
216+
type: '',
217+
references: [],
218+
} as any)
219+
).toBe(false);
220+
221+
expect(
222+
isWLMDataSourceCompatible({
223+
attributes: {
224+
dataSourceVersion: '2.19.0',
225+
title: '',
226+
endpoint: '',
227+
auth: { type: '', credentials: undefined },
228+
},
229+
id: '',
230+
type: '',
231+
references: [],
232+
} as any)
233+
).toBe(false);
234+
235+
expect(
236+
isWLMDataSourceCompatible({
237+
attributes: {
238+
dataSourceVersion: '',
239+
title: '',
240+
endpoint: '',
241+
auth: { type: '', credentials: undefined },
242+
},
243+
id: '',
244+
type: '',
245+
references: [],
246+
} as any)
247+
).toBe(false);
248+
249+
expect(
250+
isWLMDataSourceCompatible({
251+
attributes: {
252+
dataSourceVersion: '3.1.0-rc.1',
253+
title: '',
254+
endpoint: '',
255+
auth: { type: '', credentials: undefined },
256+
},
257+
id: '',
258+
type: '',
259+
references: [],
260+
} as any)
261+
).toBe(false);
262+
});
263+
});
170264
});

0 commit comments

Comments
 (0)