mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
refacto
This commit is contained in:
parent
113f2b093b
commit
9d50d97706
@ -31,10 +31,7 @@ describe('i18n - Migration - disable localization on a field', () => {
|
||||
|
||||
test("Doesn't migrate if no attribute changed (without i18n)", async () => {
|
||||
const find = jest.fn();
|
||||
const getLocalizedAttributes = jest
|
||||
.fn()
|
||||
.mockReturnValueOnce([])
|
||||
.mockReturnValueOnce([]);
|
||||
const getLocalizedAttributes = jest.fn(() => []);
|
||||
|
||||
global.strapi = {
|
||||
query: () => {
|
||||
@ -62,10 +59,7 @@ describe('i18n - Migration - disable localization on a field', () => {
|
||||
|
||||
test("Doesn't migrate if no attribute changed (with i18n)", async () => {
|
||||
const find = jest.fn();
|
||||
const getLocalizedAttributes = jest
|
||||
.fn()
|
||||
.mockReturnValueOnce(['name'])
|
||||
.mockReturnValueOnce(['name']);
|
||||
const getLocalizedAttributes = jest.fn(() => ['name']);
|
||||
global.strapi = {
|
||||
query: () => {
|
||||
find;
|
||||
|
@ -48,7 +48,7 @@ const updateFromTmpTable = async ({ model, trx, attributesToMigrate }) => {
|
||||
|
||||
const createTmpTable = async ({ ORM, attributesToMigrate, model }) => {
|
||||
const columnsToCopy = ['id', ...attributesToMigrate];
|
||||
await ORM.knex.schema.dropTableIfExists(TMP_TABLE_NAME);
|
||||
await deleteTmpTable({ ORM });
|
||||
await ORM.knex.raw(`CREATE TABLE ?? AS ??`, [
|
||||
TMP_TABLE_NAME,
|
||||
ORM.knex
|
||||
@ -65,8 +65,9 @@ const getSortedLocales = async trx => {
|
||||
try {
|
||||
const defaultLocaleRow = await trx('core_store')
|
||||
.select('value')
|
||||
.where({ key: 'plugin_i18n_default_locale' });
|
||||
defaultLocale = defaultLocaleRow[0].value;
|
||||
.where({ key: 'plugin_i18n_default_locale' })
|
||||
.first();
|
||||
defaultLocale = JSON.parse(defaultLocaleRow.value);
|
||||
} catch (e) {
|
||||
throw new Error("Could not migrate because the default locale doesn't exist");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user