From 96b74b36571aef47c4639ebd569cf1ce37f8da15 Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Thu, 20 Jan 2022 11:59:10 +0800 Subject: [PATCH 1/2] houhaoyu@huawei.com update rich ut Signed-off-by: houhaoyu Change-Id: I76c6b683e2a4559265e4a6dbad14e42c82593468 --- ace-loader/package.json | 3 ++- ace-loader/test/rich/expected/privateAttr.js | 2 ++ .../test/rich/testcase/pages/privateAttr/privateAttr.hml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ace-loader/package.json b/ace-loader/package.json index 929550f..d58fd02 100644 --- a/ace-loader/package.json +++ b/ace-loader/package.json @@ -16,7 +16,8 @@ "rich": "cd sample/rich && webpack --config ../../webpack.rich.config.js", "lite": "cd sample/lite && webpack --config ../../webpack.lite.config.js", "card": "cd sample/card && webpack --config ../../webpack.rich.config.js", - "postinstall": "node npm-install.js" + "postinstall": "node npm-install.js", + "richtest": "npm run build && cd test/rich/testcase && webpack --config ../../../webpack.rich.config.js && mocha ../test.js" }, "devDependencies": { "chai": "^3.5.0", diff --git a/ace-loader/test/rich/expected/privateAttr.js b/ace-loader/test/rich/expected/privateAttr.js index 0ed854b..3afffe0 100644 --- a/ace-loader/test/rich/expected/privateAttr.js +++ b/ace-loader/test/rich/expected/privateAttr.js @@ -468,8 +468,10 @@ }, { "type": "xcomponent", + "id": "1", "attr": { "debugLine": "pages/privateAttr/privateAttr:130", + "id": "1", "name": "function () {return this.name}", "type": "texture" } diff --git a/ace-loader/test/rich/testcase/pages/privateAttr/privateAttr.hml b/ace-loader/test/rich/testcase/pages/privateAttr/privateAttr.hml index 701d117..6790f13 100644 --- a/ace-loader/test/rich/testcase/pages/privateAttr/privateAttr.hml +++ b/ace-loader/test/rich/testcase/pages/privateAttr/privateAttr.hml @@ -127,7 +127,7 @@ - + From c013e828835cee1c5673971f3bdfeefcabc512b2 Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Thu, 20 Jan 2022 16:05:44 +0800 Subject: [PATCH 2/2] houhaoyu@huawei.com update ut Signed-off-by: houhaoyu Change-Id: Idc55ed099fb4cc0040f1078116d7a8b7b74adfd7 --- ace-loader/package.json | 5 ++++- ace-loader/test/lite/test.js | 3 ++- ace-loader/webpack.rich.config.js | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ace-loader/package.json b/ace-loader/package.json index d58fd02..144c452 100644 --- a/ace-loader/package.json +++ b/ace-loader/package.json @@ -17,7 +17,10 @@ "lite": "cd sample/lite && webpack --config ../../webpack.lite.config.js", "card": "cd sample/card && webpack --config ../../webpack.rich.config.js", "postinstall": "node npm-install.js", - "richtest": "npm run build && cd test/rich/testcase && webpack --config ../../../webpack.rich.config.js && mocha ../test.js" + "richtest": "cd test/rich/testcase && webpack --config ../../../webpack.rich.config.js && mocha ../test.js", + "litetest": "cd test/lite/testcase && webpack --config ../../../webpack.lite.config.js && mocha ../test.js", + "cardtest": "cd test/card/testcase && webpack --env utTestForCard --config ../../../webpack.rich.config.js && mocha ../test.js", + "test": "npm run build && npm run richtest && npm run litetest && npm run cardtest" }, "devDependencies": { "chai": "^3.5.0", diff --git a/ace-loader/test/lite/test.js b/ace-loader/test/lite/test.js index 92344f1..9024dec 100644 --- a/ace-loader/test/lite/test.js +++ b/ace-loader/test/lite/test.js @@ -33,9 +33,10 @@ function getJsBundle(componentName) { } function getExpectedObj(componentName) { + const matchHashComment = /\/\*(.|\n|\r)+\*\//; const filepath = path.join(__dirname, "expected", `${componentName}.js`); const expectedContent = fs.readFileSync(filepath, "utf-8"); - const expectedObj = JSON.parse(expectedContent.toString()); + const expectedObj = JSON.parse(expectedContent.toString().replace(matchHashComment, '')); return expectedObj; } diff --git a/ace-loader/webpack.rich.config.js b/ace-loader/webpack.rich.config.js index afb813e..7099b8a 100644 --- a/ace-loader/webpack.rich.config.js +++ b/ace-loader/webpack.rich.config.js @@ -178,6 +178,9 @@ let config = { } function setConfigs(env) { + if (env.utTestForCard) { + env.DEVICE_LEVEL = "card"; + } if (process.env.aceModuleJsonPath || env.aceModuleJsonPath) { process.env.compileMode = 'moduleJson'; }