Skip to content

Commit

Permalink
Merge pull request #521 from harttle/master
Browse files Browse the repository at this point in the history
抽离反解 case 到 san-html-cases
  • Loading branch information
errorrik committed Jul 31, 2020
2 parents 0c5f6b8 + 86c68c3 commit 43a4c0f
Show file tree
Hide file tree
Showing 404 changed files with 76 additions and 5,172 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ bug.html
test.html
coverage/
errorShots/
/test/karma-context.html
/test/index-reverse.html
/test/reverse/reverse.spec.js
/test/reverse.spec.js
/test/pref/tti.html
*.vscode
56 changes: 26 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"dev": "node ./tool/dev.js",
"dev:unit": "npx karma start ./test/karma.conf.js start",
"pretest": "npm run build && node ./test/reverse/build-test.js && node ./test/build-spec.js",
"pretest": "npm run build && node ./test/build-reverse-test.js && node ./test/build-spec.js",
"size": "npm run build && gzip -k dist/san.spa.modern.min.js && stat dist/san.spa.modern.min.js.gz && rm -f dist/*.gz",
"test": "npm run test:unit",
"test:unit": "npx karma start ./test/karma.conf.js --single-run",
Expand Down Expand Up @@ -48,14 +48,15 @@
"karma-sourcemap-loader": "^0.3.7",
"mustache": "^3.0.1",
"opener": "^1.5.1",
"san-anode-cases": "^3.9.0",
"san-html-cases": "^2.0.1",
"source-map": "^0.7.3",
"swig-templates": "^2.0.3",
"uglify-js": "^2.8.22",
"watch": "^1.0.2",
"wdio-jasmine-framework": "^0.3.0",
"wdio-sauce-service": "^0.4.14",
"wdio-spec-reporter": "^0.1.0",
"webdriverio": "^5.7.0",
"san-anode-cases": "^3.9.0"
"webdriverio": "^5.7.0"
}
}
21 changes: 13 additions & 8 deletions test/reverse/build-test.js → test/build-reverse-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/


const san = require('../../dist/san');
const san = require('../dist/san');
const fs = require('fs');
const path = require('path');

let htmlTpl = fs.readFileSync(path.resolve(__dirname, '..', 'index-reverse.html.tpl'), 'UTF-8');
let htmlTpl = fs.readFileSync(path.resolve(__dirname, 'index-reverse.html.tpl'), 'UTF-8');
let html = '';
let specTpls = '';

Expand Down Expand Up @@ -95,7 +95,12 @@ function buildFile(filePath) {
.replace(/;\s*$/, '');
break;

case 'result.html':
case 'data.json':
compontentData = require(abFilePath);
componentDataLiteral = fs.readFileSync(abFilePath, 'UTF-8');
break;

case 'expected.html':
result = fs.readFileSync(path.resolve(abFilePath), 'UTF-8').replace('\n', '');
break;
}
Expand All @@ -113,7 +118,7 @@ function buildFile(filePath) {
// dirName is the identity of each component
dirName = match[1];
// generate html when it has source file
if (sourceFile) {
if (sourceFile && specTpl) {
genContent({
componentClass,
componentSource,
Expand All @@ -127,15 +132,15 @@ function buildFile(filePath) {
};

function writeIn({htmlTpl, html, specTpls}) {
let karmaHtml = fs.readFileSync(path.resolve(__dirname, '..', 'karma-context.html.tpl'), 'UTF-8');
let karmaHtml = fs.readFileSync(path.resolve(__dirname, 'karma-context.html.tpl'), 'UTF-8');
fs.writeFileSync(
path.resolve(__dirname, '..', 'karma-context.html'),
path.resolve(__dirname, 'karma-context.html'),
karmaHtml.replace('##rendered-elements##', html),
'UTF-8'
);

fs.writeFileSync(
path.resolve(__dirname, '..', 'index-reverse.html'),
path.resolve(__dirname, 'index-reverse.html'),
htmlTpl.replace('##rendered-elements##', html),
'UTF-8'
);
Expand All @@ -151,7 +156,7 @@ console.log();
console.log('----- Build Reverse Specs -----');


buildFile(path.resolve(__dirname, './'));
buildFile(path.join(__dirname, '../node_modules/san-html-cases/src'));
// write into file
writeIn({htmlTpl, html, specTpls});

Expand Down
Loading

0 comments on commit 43a4c0f

Please sign in to comment.