fix: fix Apollo client cache update error for Links field (#5473)

Fixes #5437
This commit is contained in:
Thaïs
2024-05-22 10:55:24 +02:00
committed by GitHub
parent d1cbd709bd
commit 474dfd7bd8
8 changed files with 159 additions and 15 deletions

View File

@ -0,0 +1,58 @@
import { pascalCase } from '../pascalCase';
describe('pascalCase', () => {
it('converts a string to pascal case', () => {
// Given
const input = 'HELLO_WORLD';
// When
const result = pascalCase(input);
// Then
expect(result).toBe('HelloWorld');
});
it('handles empty strings', () => {
// Given
const input = '';
// When
const result = pascalCase(input);
// Then
expect(result).toBe('');
});
it('handles strings with only one word', () => {
// Given
const input = 'hello';
// When
const result = pascalCase(input);
// Then
expect(result).toBe('Hello');
});
it('handles strings with several words, spaces and special characters', () => {
// Given
const input = '& Hello world! How are you today? #';
// When
const result = pascalCase(input);
// Then
expect(result).toBe('HelloWorldHowAreYouToday');
});
it('handles strings with leading and trailing spaces', () => {
// Given
const input = ' hello_world ';
// When
const result = pascalCase(input);
// Then
expect(result).toBe('HelloWorld');
});
});

View File

@ -1,9 +0,0 @@
import { isNonEmptyString } from '@sniptt/guards';
export const lowerAndCapitalize = (stringToCapitalize: string) => {
if (!isNonEmptyString(stringToCapitalize)) return '';
const loweredString = stringToCapitalize.toLowerCase();
return loweredString[0].toUpperCase() + loweredString.slice(1);
};

View File

@ -0,0 +1,5 @@
import camelCase from 'lodash.camelcase';
import { capitalize } from '~/utils/string/capitalize';
export const pascalCase = (str: string) => capitalize(camelCase(str));