-
Notifications
You must be signed in to change notification settings - Fork 0
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
6d8d4ca
commit 40e34ec
Showing
6 changed files
with
48 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,26 @@ | ||
import {isValidVariables} from "./explain"; | ||
import {cleanExplainGraphQLVariables, isGraphQLValidVariables} from "./explain"; | ||
|
||
describe('Explain service', () => { | ||
describe('isValidVariables', () => { | ||
it('Test if ', () => { | ||
expect(isValidVariables({requestType:'product_catalog', search:'', localizedCatalog:'1'}, 'search')).toEqual('Hello there') | ||
}) | ||
}) | ||
|
||
describe('firstLetterLowercase', () => { | ||
it('Should set first letter to lowercase', () => { | ||
expect(firstLetterLowercase('Hello there')).toEqual('hello there') | ||
}) | ||
}) | ||
|
||
describe('getNameFromDefault', () => { | ||
it('Should get the name without the default part', () => { | ||
expect(getNameFromDefault('defaultMaxSize')).toEqual('maxSize') | ||
}) | ||
}) | ||
|
||
describe('humanize', () => { | ||
it('Should humanize the label', () => { | ||
expect(humanize('defaultLabel')).toEqual('Default label') | ||
}) | ||
}) | ||
|
||
describe('getHeadTitle', () => { | ||
it('Should add Gally at the end of string getHeadTitle', () => { | ||
expect(getHeadTitle('Catégories')).toEqual('Catégories - Gally') | ||
}) | ||
}) | ||
|
||
describe('getFieldLabelTranslationArgs', () => { | ||
it('Should return field label (args for translation)', () => { | ||
expect(getFieldLabelTranslationArgs('defaultLabel')).toEqual([ | ||
'fields.defaultLabel', | ||
'Default label', | ||
]) | ||
expect(getFieldLabelTranslationArgs('defaultLabel', 'metadata')).toEqual([ | ||
'resources.metadata.fields.defaultLabel', | ||
'Default label', | ||
]) | ||
}) | ||
}) | ||
|
||
describe('addPrefixKeyObject', () => { | ||
it('Should add the prefix "category", on all keys of the object', () => { | ||
expect( | ||
addPrefixKeyObject( | ||
{ localizedCatalog: 'com_fr', search: 'bag' }, | ||
'category' | ||
) | ||
).toEqual({ categoryLocalizedCatalog: 'com_fr', categorySearch: 'bag' }) | ||
}) | ||
}) | ||
|
||
describe('formatPrice', () => { | ||
it('Should format price', () => { | ||
expect(formatPrice(100, 'USD', 'fr-FR')).toContain('100,00') | ||
expect(formatPrice(100, 'USD', 'fr-FR')).toContain('$US') | ||
}) | ||
}) | ||
describe('getIdFromIri', () => { | ||
it('Should format price', () => { | ||
expect(getIdFromIri('/localized_catalog/1')).toEqual('1') | ||
expect(getIdFromIri('/localized_catalog/random/10')).toEqual('10') | ||
it('Should test if explain GraphQL variables are valid ', () => { | ||
expect(isGraphQLValidVariables({ | ||
requestType:'product_catalog', search:'bag', localizedCatalog:'1' | ||
}, 'search')).toEqual(true) | ||
expect(isGraphQLValidVariables({ | ||
requestType:'product_catalog', search:'', localizedCatalog:'1' | ||
}, 'search')).toEqual(false) | ||
expect(isGraphQLValidVariables({ | ||
requestType:'product_catalog', search:'', localizedCatalog:'' | ||
}, 'search')).toEqual(false) | ||
}) | ||
}) | ||
|
||
describe('cleanExplainGraphQLVariables', () => { | ||
it('Should clean explain GraphQL variables', () => { | ||
expect(cleanExplainGraphQLVariables({ | ||
requestType:'product_catalog', search:'bag', localizedCatalog:'1', category: { id: 'cat_7', name: 'Bag', level: 2, isVirtual: false, path: 'cat_2/cat_8' } | ||
}, 'search')).toEqual({ | ||
requestType:'product_catalog', search:'bag', localizedCatalog:'1', category: { id: 'cat_7', name: 'Bag', level: 2, isVirtual: false, path: 'cat_2/cat_8' }}) | ||
}) | ||
}) | ||
}) |
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