1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-06 01:15:28 +02:00
unleash.unleash/src/lib/features/metrics/instance/findOutdatedSdks.test.ts
2024-03-14 15:47:34 +01:00

60 lines
1.9 KiB
TypeScript

import { findOutdatedSDKs } from './findOutdatedSdks';
describe('findOutdatedSDKs', () => {
it('should return an empty array when all SDKs are up to date', () => {
const sdkVersions = [
'unleash-client-node:6.0.0',
'unleash-client-php:3.0.0',
];
const result = findOutdatedSDKs(sdkVersions);
expect(result).toEqual([]);
});
it('should return an array with outdated SDKs', () => {
const sdkVersions = [
'unleash-client-node:3.9.9',
'unleash-client-php:0.9.9',
];
const result = findOutdatedSDKs(sdkVersions);
expect(result).toEqual([
'unleash-client-node:3.9.9',
'unleash-client-php:0.9.9',
]);
});
it('should ignore SDKs not in the config', () => {
const sdkVersions = ['unleash-client-pony:2.0.0'];
const result = findOutdatedSDKs(sdkVersions);
expect(result).toEqual([]);
});
it('should handle and remove duplicate SDK versions', () => {
const sdkVersions = [
'unleash-client-node:3.8.0',
'unleash-client-node:3.8.0',
'unleash-client-php:0.9.0',
'unleash-client-php:0.9.0',
];
const result = findOutdatedSDKs(sdkVersions);
expect(result).toEqual([
'unleash-client-node:3.8.0',
'unleash-client-php:0.9.0',
]);
});
it('should correctly handle semver versions', () => {
const sdkVersions = [
'unleash-client-node:6.1.0',
'unleash-client-php:3.20.3-beta.0',
];
const result = findOutdatedSDKs(sdkVersions);
expect(result).toEqual([]);
});
it('should ignore invalid SDK versions', () => {
const sdkVersions = ['unleash-client-node', '1.2.3', null];
const result = findOutdatedSDKs(sdkVersions);
expect(result).toEqual([]);
});
});