Write more tests (#8799)

This commit is contained in:
Baptiste Devessier
2024-11-28 17:43:15 +01:00
committed by GitHub
parent b857d45182
commit 38b83f0866
11 changed files with 387 additions and 22 deletions

View File

@ -0,0 +1,25 @@
import { castToString } from '../castToString';
it('returns an empty string when undefined is provided', () => {
expect(castToString(undefined)).toBe('');
});
it('returns an empty string when null is provided', () => {
expect(castToString(undefined)).toBe('');
});
it('returns an empty string when an empty string is provided', () => {
expect(castToString('')).toBe('');
});
it('preserves strings', () => {
expect(castToString('test')).toBe('test');
});
it('casts numbers to strings', () => {
expect(castToString(21)).toBe('21');
});
it('casts booleans to strings', () => {
expect(castToString(true)).toBe('true');
});

View File

@ -1,3 +0,0 @@
export const isAnObject = (obj: any): obj is object => {
return typeof obj === 'object' && obj !== null && Object.keys(obj).length > 0;
};

View File

@ -1,16 +0,0 @@
import { Observable } from '@apollo/client';
export const promiseToObservable = <T>(promise: Promise<T>) =>
new Observable<T>((subscriber) => {
promise.then(
(value) => {
if (subscriber.closed) {
return;
}
subscriber.next(value);
subscriber.complete();
},
(err) => subscriber.error(err),
);
});