Skip to content

Commit 8d8e035

Browse files
authored
fix: integration test cases (#7781)
1 parent 28f0c6a commit 8d8e035

File tree

30 files changed

+43
-40
lines changed

30 files changed

+43
-40
lines changed

packages/runtime/plugin-i18n/src/runtime/context.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ export const useModernI18n = (
169169

170170
// Use history API to navigate without page reload
171171
window.history.pushState(null, '', newUrl);
172-
} else if (updateLanguage) {
172+
}
173+
174+
// Update language state after URL update
175+
if (updateLanguage) {
173176
updateLanguage(newLang);
174177
}
175178
} catch (error) {

tests/integration/alias-set/tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('alias set build', () => {
2020
const buildRes = await modernBuild(appDir);
2121
expect(buildRes.code === 0).toBe(true);
2222
expect(existsSync('route.json')).toBe(true);
23-
expect(existsSync('html/main/index.html')).toBe(true);
23+
expect(existsSync('html/index/index.html')).toBe(true);
2424
});
2525
});
2626

tests/integration/asset-prefix/tests/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('asset prefix', () => {
3535
});
3636
test(`should generate assetPrefix correctly when dev.assetPrefix is true`, async () => {
3737
const HTML = readFileSync(
38-
path.join(appDir, 'dist/html/main/index.html'),
38+
path.join(appDir, 'dist/html/index/index.html'),
3939
'utf-8',
4040
);
4141
expect(
@@ -47,7 +47,7 @@ describe('asset prefix', () => {
4747
const expected = `http://${DEFAULT_DEV_HOST}:${appPort}`;
4848

4949
const mainJs = readFileSync(
50-
path.join(appDir, 'dist/static/js/main.js'),
50+
path.join(appDir, 'dist/static/js/index.js'),
5151
'utf-8',
5252
);
5353

tests/integration/async-entry/tests/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ describe('generate async entry', () => {
1010

1111
expect(
1212
readFileSync(
13-
path.resolve(appDir, `node_modules/.modern-js/main/index.jsx`),
13+
path.resolve(appDir, `node_modules/.modern-js/index/index.jsx`),
1414
'utf8',
1515
),
1616
).toContain(`import { createRoot } from '@modern-js/runtime/react';`);
1717

1818
expect(
1919
readFileSync(
20-
path.resolve(appDir, `node_modules/.modern-js/main/bootstrap.jsx`),
20+
path.resolve(appDir, `node_modules/.modern-js/index/bootstrap.jsx`),
2121
'utf8',
2222
),
23-
).toContain(`import(/* webpackChunkName: "async-main" */ './index');`);
23+
).toContain(`import(/* webpackChunkName: "async-index" */ './index');`);
2424
});
2525
});

tests/integration/basic-app/tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('test build', () => {
103103
test(`should get right alias build!`, async () => {
104104
expect(buildRes.code === 0).toBe(true);
105105
expect(existsSync('route.json')).toBe(true);
106-
expect(existsSync('html/main/index.html')).toBe(true);
106+
expect(existsSync('html/index/index.html')).toBe(true);
107107
});
108108

109109
test('should visit page correctly', async () => {

tests/integration/clean-dist-path/tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('clean dist path', () => {
66
test(`should not clean dist path when output.cleanDistPath is false`, async () => {
77
const appDir = path.resolve(__dirname, '..');
88
const tempFile = path.join(appDir, 'dist/foo.txt');
9-
const htmlFile = path.join(appDir, 'dist/html/main/index.html');
9+
const htmlFile = path.join(appDir, 'dist/html/index/index.html');
1010
fs.outputFileSync(tempFile, 'foo');
1111
await modernBuild(appDir);
1212
expect(fs.existsSync(tempFile)).toBeTruthy();

tests/integration/compatibility/tests/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ function existsSync(filePath: string) {
1111
test('should generate es5 artifact and pass check syntax by default', async () => {
1212
const appDir = path.resolve(__dirname, '..');
1313
await modernBuild(appDir);
14-
expect(existsSync('html/main/index.html')).toBeTruthy();
15-
expect(existsSync('static/js/main.js')).toBeTruthy();
14+
expect(existsSync('html/index/index.html')).toBeTruthy();
15+
expect(existsSync('static/js/index.js')).toBeTruthy();
1616
});

tests/integration/custom-dist-path/tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test(`should allow distPath.root to be an absolute path`, async () => {
88

99
const distPath = path.join(appDir, 'dist/foo');
1010
const configFile = path.join(distPath, OUTPUT_CONFIG_FILE);
11-
const htmlFile = path.join(distPath, 'html/main/index.html');
11+
const htmlFile = path.join(distPath, 'html/index/index.html');
1212
expect(fs.existsSync(configFile)).toBeTruthy();
1313
expect(fs.existsSync(htmlFile)).toBeTruthy();
1414
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`custom template should allow to custom template by html.template option 1`] = `"<!doctype html><html><head><title>Hello World</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no,viewport-fit=cover,minimum-scale=1,maximum-scale=1,user-scalable=no"><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="renderer" content="webkit"><meta name="layoutmode" content="standard"><meta name="imagemode" content="force"><meta name="wap-font-scale" content="no"><meta name="format-detection" content="telephone=no"><script defer="defer" src="/static/js/main.js"></script></head><body><div id="root"></div></body></html>"`;
3+
exports[`custom template should allow to custom template by html.template option 1`] = `"<!doctype html><html><head><title>Hello World</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no,viewport-fit=cover,minimum-scale=1,maximum-scale=1,user-scalable=no"><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="renderer" content="webkit"><meta name="layoutmode" content="standard"><meta name="imagemode" content="force"><meta name="wap-font-scale" content="no"><meta name="format-detection" content="telephone=no"><script defer="defer" src="/static/js/index.js"></script></head><body><div id="root"></div></body></html>"`;

tests/integration/custom-template/tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('custom template', () => {
99
await modernBuild(appDir);
1010

1111
expect(
12-
readFileSync(path.resolve(appDir, `dist/html/main/index.html`), 'utf8'),
12+
readFileSync(path.resolve(appDir, `dist/html/index/index.html`), 'utf8'),
1313
).toMatchSnapshot();
1414
});
1515
});

0 commit comments

Comments
 (0)