-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9911 from marmelab/use-source-prefix-context-in-a…
…rray-input-and-simple-form-iterator `<ArrayInput>` uses `SourceContext` instead of cloning children
- Loading branch information
Showing
22 changed files
with
676 additions
and
230 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { getRecordForLocale } from './useTranslatable'; | ||
describe('useTranslatable', () => { | ||
describe('getRecordForLocale', () => { | ||
it('should return a record where translatable fields have their values set to the value of the given locale', () => { | ||
// Given the record { title: { en: 'title_en', fr: 'title_fr' } } and the locale 'fr', | ||
// the record for the locale 'fr' will be { title: 'title_fr' } | ||
const record = { | ||
fractal: true, | ||
title: { en: 'title_en', fr: 'title_fr' }, | ||
items: [ | ||
{ description: { en: 'item1_en', fr: 'item1_fr' } }, | ||
{ description: { en: 'item2_en', fr: 'item2_fr' } }, | ||
], | ||
}; | ||
|
||
const recordForLocale = getRecordForLocale(record, 'fr'); | ||
|
||
expect(recordForLocale).toEqual({ | ||
fractal: true, | ||
title: 'title_fr', | ||
items: [ | ||
{ description: 'item1_fr' }, | ||
{ description: 'item2_fr' }, | ||
], | ||
}); | ||
}); | ||
|
||
it('should return the record as is if it is empty', () => { | ||
const record = {}; | ||
const recordForLocale = getRecordForLocale(record, 'fr'); | ||
expect(recordForLocale).toEqual({}); | ||
}); | ||
|
||
it('should return the record as is if it is undefined', () => { | ||
const record = undefined; | ||
const recordForLocale = getRecordForLocale(record, 'fr'); | ||
expect(recordForLocale).toEqual(undefined); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.