mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
test fixing
This commit is contained in:
parent
2884b3594b
commit
fd00987eff
@ -56,6 +56,7 @@ describe('localeQueryParamsMiddleware', () => {
|
||||
const nextFn = jest.fn();
|
||||
const action = {
|
||||
type: 'ContentManager/ListView/SET_LIST_LAYOUT ',
|
||||
displayedHeaders: [],
|
||||
contentType: {
|
||||
pluginOptions: {
|
||||
i18n: { localized: true },
|
||||
@ -67,11 +68,13 @@ describe('localeQueryParamsMiddleware', () => {
|
||||
middleware(nextFn)(action);
|
||||
|
||||
expect(nextFn).toBeCalledWith(action);
|
||||
expect(action).toEqual({
|
||||
contentType: { pluginOptions: { i18n: { localized: true } } },
|
||||
initialParams: { plugins: { i18n: { locale: null } } },
|
||||
type: 'ContentManager/ListView/SET_LIST_LAYOUT ',
|
||||
});
|
||||
// The anonymous function of cellFormatter creates problem, because it's anonymous
|
||||
// In our scenario, it's even more tricky because we use a closure in order to pass
|
||||
// the locales.
|
||||
// Stringifying the action allows us to have a name inside the expectation for the "cellFormatter" key
|
||||
expect(JSON.stringify(action)).toBe(
|
||||
'{"type":"ContentManager/ListView/SET_LIST_LAYOUT ","displayedHeaders":[{"key":"__locale_key__","fieldSchema":{"type":"string"},"metadatas":{"label":"Content available in","searchable":false,"sortable":false},"name":"locales"}],"contentType":{"pluginOptions":{"i18n":{"localized":true}}},"initialParams":{"plugins":{"i18n":{"locale":null}}}}'
|
||||
);
|
||||
});
|
||||
|
||||
it('adds a key to plugins with a locale when initialParams has a plugins key and the field is localized', () => {
|
||||
@ -79,6 +82,7 @@ describe('localeQueryParamsMiddleware', () => {
|
||||
const nextFn = jest.fn();
|
||||
const action = {
|
||||
type: 'ContentManager/ListView/SET_LIST_LAYOUT ',
|
||||
displayedHeaders: [],
|
||||
contentType: {
|
||||
pluginOptions: {
|
||||
i18n: { localized: true },
|
||||
@ -94,10 +98,8 @@ describe('localeQueryParamsMiddleware', () => {
|
||||
middleware(nextFn)(action);
|
||||
|
||||
expect(nextFn).toBeCalledWith(action);
|
||||
expect(action).toEqual({
|
||||
contentType: { pluginOptions: { i18n: { localized: true } } },
|
||||
initialParams: { plugins: { i18n: { locale: null }, hello: 'world' } },
|
||||
type: 'ContentManager/ListView/SET_LIST_LAYOUT ',
|
||||
});
|
||||
expect(JSON.stringify(action)).toBe(
|
||||
'{"type":"ContentManager/ListView/SET_LIST_LAYOUT ","displayedHeaders":[{"key":"__locale_key__","fieldSchema":{"type":"string"},"metadatas":{"label":"Content available in","searchable":false,"sortable":false},"name":"locales"}],"contentType":{"pluginOptions":{"i18n":{"localized":true}}},"initialParams":{"plugins":{"hello":"world","i18n":{"locale":null}}}}'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user