Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Sep 12, 2023
1 parent 8ad5db2 commit d1c3729
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion __tests__/utils/preprocessor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = {
process(src, path) {
return {
code: src.replace(/module\.hot/g, 'global.mockModule.hot'),
code: src
.replace(/module\.hot/g, 'global.mockModule.hot')
.replace(/import\.meta\.hot/g, 'global.mockImport.meta.hot'),
};
},
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let changedData = {};
jest.mock('../lib/trigger.js', () => {
jest.mock('../../lib/webpack/trigger.js', () => {
return changedData;
});

Expand All @@ -9,7 +9,7 @@ global.mockModule = {
},
};

const applyClientHMR = require('../lib/client-hmr');
const applyClientHMR = require('../../lib/webpack/client-hmr');

function whenHotTriggeredWith(changedFiles) {
changedData.changedFiles = changedFiles;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const loader = require('../lib/webpack/loader');
const loader = require('../../lib/webpack/loader');

describe('loader', () => {
let context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const changedData = {};

jest.mock('../lib/trigger.js', () => {
jest.mock('../../lib/webpack/trigger.js', () => {
return changedData;
});
const applyServerHMR = require('../lib/server-hmr');
const plugin = require('../lib/webpack/plugin');
const applyClientHMR = require('../lib/client-hmr');
const applyServerHMR = require('../../lib/webpack/server-hmr');
const plugin = require('../../lib/webpack/plugin');

function whenNativeHMRTriggeredWith(changedFiles) {
changedData.changedFiles = changedFiles;
Expand Down
2 changes: 2 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@ module.exports = {
printList: printList,
extractList: extractList,
log: log,
createLoggerOnce: createLoggerOnce,
uniqueList: uniqueList,
reloadTranslations: reloadTranslations,
};
3 changes: 1 addition & 2 deletions lib/webpack/client-hmr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { extractList, printList, reloadTranslations, log } = require('./utils');

const { extractList, printList, reloadTranslations, log } = require('../utils');

module.exports = function applyClientHMR(i18nOrGetter) {
if (module.hot) {
Expand Down
4 changes: 2 additions & 2 deletions lib/webpack/server-hmr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { extractList, printList, uniqueList, createLoggerOnce } = require('./utils');
const { extractList, printList, uniqueList, createLoggerOnce } = require('../utils');

module.exports = function applyServerHMR(i18nOrGetter) {
const pluginName = `\x1b[35m\x1b[1m${'I18NextHMR'}\x1b[0m\x1b[39m`;
Expand Down Expand Up @@ -51,7 +51,7 @@ module.exports = function applyServerHMR(i18nOrGetter) {
} else {
logOnce(`Server HMR has started - callback mode`);

const HMRPlugin = require('./webpack/plugin');
const HMRPlugin = require('./plugin');
HMRPlugin.addListener(reloadServerTranslation);
}
};
File renamed without changes.

0 comments on commit d1c3729

Please sign in to comment.