-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0bf8e4
commit 81e362a
Showing
28 changed files
with
223 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
packages/twenty-front/src/utils/__tests__/parseApolloStoreFieldName.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { parseApolloStoreFieldName } from '../parseApolloStoreFieldName'; | ||
|
||
describe('parseApolloStoreFieldName', () => { | ||
it('returns an empty object if string is not a valid store field name', () => { | ||
const result = parseApolloStoreFieldName('////'); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
it('returns the field name and parsed variables if they exist', () => { | ||
const result = parseApolloStoreFieldName('fieldName({"key":"value"})'); | ||
expect(result).toEqual({ | ||
fieldName: 'fieldName', | ||
fieldVariables: { key: 'value' }, | ||
}); | ||
}); | ||
|
||
it('returns only the field name if the variables cannot be parsed', () => { | ||
const result = parseApolloStoreFieldName('fieldName(notJson)'); | ||
expect(result).toEqual({ | ||
fieldName: 'fieldName', | ||
}); | ||
}); | ||
|
||
it('returns only the field name if there are no variables', () => { | ||
const result = parseApolloStoreFieldName('fieldName'); | ||
expect(result).toEqual({ | ||
fieldName: 'fieldName', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { sortAsc, sortDesc, sortNullsFirst, sortNullsLast } from '../sort'; | ||
|
||
describe('sort', () => { | ||
describe('sortNullsFirst', () => { | ||
it('should sort nulls first', () => { | ||
expect(sortNullsFirst(null, 'a')).toBe(-1); | ||
expect(sortNullsFirst('a', null)).toBe(1); | ||
expect(sortNullsFirst('a', 'a')).toBe(0); | ||
}); | ||
}); | ||
|
||
describe('sortNullsLast', () => { | ||
it('should sort nulls last', () => { | ||
expect(sortNullsLast(null, 'a')).toBe(1); | ||
expect(sortNullsLast('a', null)).toBe(-1); | ||
expect(sortNullsLast('a', 'a')).toBe(0); | ||
}); | ||
}); | ||
|
||
describe('sortAsc', () => { | ||
it('should sort in ascending order', () => { | ||
expect(sortAsc('a', 'b')).toBe(-1); | ||
expect(sortAsc('b', 'a')).toBe(1); | ||
expect(sortAsc('a', 'a')).toBe(0); | ||
}); | ||
}); | ||
|
||
describe('sortDesc', () => { | ||
it('should sort in descending order', () => { | ||
expect(sortDesc('a', 'b')).toBe(1); | ||
expect(sortDesc('b', 'a')).toBe(-1); | ||
expect(sortDesc('a', 'a')).toBe(0); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
packages/twenty-front/src/utils/array/__tests__/groupArrayItemsBy.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { groupArrayItemsBy } from '../groupArrayItemsBy'; | ||
|
||
describe('groupArrayItemsBy', () => { | ||
it('groups an array of objects by a computed key', () => { | ||
// Given | ||
const array = [ | ||
{ id: '1', type: 'fruit', value: 'apple' }, | ||
{ id: '2', type: 'fruit', value: 'banana' }, | ||
{ id: '3', type: 'vegetable', value: 'carrot' }, | ||
]; | ||
const computeGroupKey = ({ type }: (typeof array)[0]) => type; | ||
|
||
// When | ||
const result = groupArrayItemsBy(array, computeGroupKey); | ||
|
||
// Then | ||
expect(result).toEqual({ | ||
fruit: [ | ||
{ id: '1', type: 'fruit', value: 'apple' }, | ||
{ id: '2', type: 'fruit', value: 'banana' }, | ||
], | ||
vegetable: [{ id: '3', type: 'vegetable', value: 'carrot' }], | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.