Skip to content

Commit bda840e

Browse files
LeoYuaneternalsky
authored andcommitted
chore: fix CodeGen UT failure
1 parent deeeed2 commit bda840e

File tree

1 file changed

+45
-1
lines changed
  • modules/code-generator/tests/fixtures/test-cases/react-app/demo9-datasource-engine/expected/demo-project/src/pages/$

1 file changed

+45
-1
lines changed

modules/code-generator/tests/fixtures/test-cases/react-app/demo9-datasource-engine/expected/demo-project/src/pages/$/index.jsx

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import React from 'react';
44

55
import { Switch } from '@alifd/next';
66

7+
import { createJsonpHandler as __$$createJsonpRequestHandler } from '@alilc/lowcode-datasource-jsonp-handler';
8+
9+
import { create as __$$createDataSourceEngine } from '@alilc/lowcode-datasource-engine/runtime';
10+
711
import utils from '../../utils';
812

913
import * as __$$i18n from '../../i18n';
@@ -15,6 +19,20 @@ import './index.css';
1519
class $$Page extends React.Component {
1620
_context = this;
1721

22+
_dataSourceConfig = this._defineDataSourceConfig();
23+
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this, {
24+
runtimeConfig: true,
25+
requestHandlersMap: { jsonp: __$$createJsonpRequestHandler() },
26+
});
27+
28+
get dataSourceMap() {
29+
return this._dataSourceEngine.dataSourceMap || {};
30+
}
31+
32+
reloadDataSource = async () => {
33+
await this._dataSourceEngine.reloadDataSource();
34+
};
35+
1836
get constants() {
1937
return __$$constants || {};
2038
}
@@ -33,7 +51,33 @@ class $$Page extends React.Component {
3351

3452
$$ = () => [];
3553

36-
componentDidMount() {}
54+
_defineDataSourceConfig() {
55+
const _this = this;
56+
return {
57+
list: [
58+
{
59+
id: 'todos',
60+
isInit: function () {
61+
return true;
62+
},
63+
type: 'jsonp',
64+
options: function () {
65+
return {
66+
method: 'GET',
67+
uri: 'https://a0ee9135-6a7f-4c0f-a215-f0f247ad907d.mock.pstmn.io',
68+
};
69+
},
70+
dataHandler: function dataHandler(data) {
71+
return data.data;
72+
},
73+
},
74+
],
75+
};
76+
}
77+
78+
componentDidMount() {
79+
this._dataSourceEngine.reloadDataSource();
80+
}
3781

3882
render() {
3983
const __$$context = this._context || this;

0 commit comments

Comments
 (0)