Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
Chameleon
提交
079774ea
C
Chameleon
项目概览
DiDi
/
Chameleon
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Chameleon
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
079774ea
编写于
5月 08, 2019
作者:
Y
yylgit
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
interface-parser unit test
上级
84b1201e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
149 addition
and
25 deletion
+149
-25
packages/chameleon-tool-utils/test/index.test.js
packages/chameleon-tool-utils/test/index.test.js
+19
-1
packages/mvvm-interface-parser/index.js
packages/mvvm-interface-parser/index.js
+1
-6
packages/mvvm-interface-parser/lib/check.js
packages/mvvm-interface-parser/lib/check.js
+1
-0
packages/mvvm-interface-parser/package.json
packages/mvvm-interface-parser/package.json
+8
-1
packages/mvvm-interface-parser/test/check.test.js
packages/mvvm-interface-parser/test/check.test.js
+40
-0
packages/mvvm-interface-parser/test/getInterfaceCode.js
packages/mvvm-interface-parser/test/getInterfaceCode.js
+0
-7
packages/mvvm-interface-parser/test/getInterfaceCode.test.js
packages/mvvm-interface-parser/test/getInterfaceCode.test.js
+28
-0
packages/mvvm-interface-parser/test/getMethodCode.js
packages/mvvm-interface-parser/test/getMethodCode.js
+0
-10
packages/mvvm-interface-parser/test/getMethodCode.test.js
packages/mvvm-interface-parser/test/getMethodCode.test.js
+28
-0
packages/mvvm-interface-parser/test/lib/components/third.interface
...mvvm-interface-parser/test/lib/components/third.interface
+20
-0
packages/mvvm-interface-parser/test/lib/components/thirdinterface.js
...vm-interface-parser/test/lib/components/thirdinterface.js
+3
-0
packages/mvvm-interface-parser/test/lib/components/thirdmethod.js
.../mvvm-interface-parser/test/lib/components/thirdmethod.js
+1
-0
未找到文件。
packages/chameleon-tool-utils/test/index.test.js
浏览文件 @
079774ea
...
...
@@ -753,5 +753,23 @@ describe('index.js', function () {
expect
(
result
).
to
.
be
.
equal
(
'
/user/cml/name.web_3123123123123sd.cml
'
);
})
it
(
`resolveSync relativePath`
,
function
()
{
let
filePath
=
path
.
join
(
__dirname
,
'
index.test.js
'
);
let
relativePath
=
'
./testlib/index.cml
'
;
let
result
=
_
.
resolveSync
(
filePath
,
relativePath
);
expect
(
result
).
to
.
be
.
equal
(
path
.
join
(
__dirname
,
'
./testlib/index.cml
'
));
})
it
(
`resolveSync npmPath`
,
function
()
{
let
filePath
=
path
.
join
(
__dirname
,
'
index.test.js
'
);
let
relativePath
=
'
glob
'
;
let
result
=
_
.
resolveSync
(
filePath
,
relativePath
);
console
.
log
(
result
)
expect
(
!!~
result
.
indexOf
(
'
glob
'
)).
to
.
be
.
equal
(
true
);
})
})
packages/mvvm-interface-parser/index.js
浏览文件 @
079774ea
...
...
@@ -3,14 +3,9 @@ const cmlUtils = require('chameleon-tool-utils');
const
{
getCode
}
=
require
(
'
./lib/check.js
'
);
const
getInterfaceCode
=
require
(
'
./lib/getInterfaceCode.js
'
);
const
getMethodCode
=
require
(
'
./lib/getMethodCode.js
'
);
const
path
=
require
(
'
path
'
);
const
defaultResolve
=
function
(
filePath
,
relativePath
)
{
return
path
.
resolve
(
path
.
dirname
(
filePath
),
relativePath
)
}
// resolve 用于处理interface中include文件中的引用
module
.
exports
=
function
({
cmlType
,
media
,
source
,
filePath
,
check
,
resolve
=
defaultResolve
})
{
module
.
exports
=
function
({
cmlType
,
media
,
source
,
filePath
,
check
,
resolve
=
cmlUtils
.
resolveSync
})
{
let
interfaceResut
=
getInterfaceCode
({
interfacePath
:
filePath
,
content
:
source
})
let
methodResult
=
getMethodCode
({
interfacePath
:
filePath
,
content
:
source
,
cmlType
,
resolve
})
...
...
packages/mvvm-interface-parser/lib/check.js
浏览文件 @
079774ea
...
...
@@ -43,6 +43,7 @@ const handlExport = function (ast) {
* @param {Object} obj 需要处理的对象
* @return {Object} 对象
*/
/* istanbul ignore next */
const
wrapper
=
function
(
obj
)
{
const
className
=
obj
.
constructor
.
name
;
/* eslint-disable no-undef */
...
...
packages/mvvm-interface-parser/package.json
浏览文件 @
079774ea
...
...
@@ -3,7 +3,8 @@
"version"
:
"0.4.0-mvvm.6"
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
"cover"
:
"istanbul cover --report lcov _mocha -- -R spec --recursive"
,
"test"
:
"mocha --recursive --reporter spec"
},
"author"
:
"Chameleon-Team"
,
"license"
:
"Apache"
,
...
...
@@ -15,5 +16,11 @@
"@babel/types"
:
"^7.3.4"
,
"chameleon-tool-utils"
:
"0.4.0-mvvm.6"
,
"runtime-check"
:
"0.4.0-mvvm.6"
},
"devDependencies"
:
{
"chai"
:
"^4.2.0"
,
"eslint"
:
"^5.9.0"
,
"istanbul"
:
"^0.4.5"
,
"mocha"
:
"^5.2.0"
}
}
\ No newline at end of file
packages/mvvm-interface-parser/test/check.test.js
0 → 100644
浏览文件 @
079774ea
const
{
getCode
}
=
require
(
'
../lib/check.js
'
);
const
expect
=
require
(
'
chai
'
).
expect
;
let
code
=
`
interface Interface1Interface {
getMsg(msg: String): String;
}
class Method implements Interface1Interface {
getMsg(msg) {
return 'web:' + msg;
}
}
export default new Method();
`
let
result
=
getCode
(
code
,{
cmlType
:
'
wx
'
,
filePath
:
'
/user/name.cml
'
,
enableTypes
:
[]
})
describe
(
'
check.js wx
'
,
function
()
{
it
(
'
getCode
'
,
function
()
{
expect
(
!!~
result
.
indexOf
(
'
export default __OBJECT__WRAPPER__
'
)).
to
.
be
.
equal
(
true
);
})
})
let
result2
=
getCode
(
code
,{
cmlType
:
'
weex
'
,
filePath
:
'
/user/name.cml
'
,
enableTypes
:
[]
})
describe
(
'
check.js weex
'
,
function
()
{
it
(
'
getCode
'
,
function
()
{
expect
(
!!~
result2
.
indexOf
(
'
export default __OBJECT__WRAPPER__
'
)).
to
.
be
.
equal
(
true
);
})
})
packages/mvvm-interface-parser/test/getInterfaceCode.js
已删除
100644 → 0
浏览文件 @
84b1201e
const
getInterfaceCode
=
require
(
'
../lib/getInterfaceCode.js
'
);
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
const
interfacePath
=
path
.
join
(
__dirname
,
'
./lib/components/second/second.interface
'
);
const
content
=
fs
.
readFileSync
(
interfacePath
,
{
encoding
:
'
utf-8
'
})
let
result1
=
getInterfaceCode
({
interfacePath
,
content
});
packages/mvvm-interface-parser/test/getInterfaceCode.test.js
0 → 100644
浏览文件 @
079774ea
const
expect
=
require
(
'
chai
'
).
expect
;
const
getInterfaceCode
=
require
(
'
../lib/getInterfaceCode.js
'
);
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
describe
(
'
mvvm-interface-parser/getInterfaceCode
'
,
function
()
{
it
(
'
getInterfaceCode
'
,
function
()
{
const
interfacePath
=
path
.
join
(
__dirname
,
'
./lib/components/second/second.interface
'
);
const
content
=
fs
.
readFileSync
(
interfacePath
,
{
encoding
:
'
utf-8
'
})
let
result1
=
getInterfaceCode
({
interfacePath
,
content
});
let
firstInterfacePath
=
path
.
join
(
__dirname
,
'
./lib/components/first/first.interface
'
)
expect
(
result1
.
content
).
to
.
be
.
equal
(
'
\n
interface FirstInterface {
\n
getMsg(msg: String): String;
\n
}
\n\n
'
)
expect
(
result1
.
contentFilePath
).
to
.
be
.
equal
(
firstInterfacePath
)
expect
(
!!~
result1
.
devDeps
.
indexOf
(
firstInterfacePath
)).
to
.
be
.
equal
(
true
)
})
it
(
'
getInterfaceCode src
'
,
function
()
{
const
interfacePath
=
path
.
join
(
__dirname
,
'
./lib/components/third.interface
'
);
const
content
=
fs
.
readFileSync
(
interfacePath
,
{
encoding
:
'
utf-8
'
})
let
result1
=
getInterfaceCode
({
interfacePath
,
content
});
let
contentPath
=
path
.
join
(
__dirname
,
'
./lib/components/thirdinterface.js
'
)
expect
(
result1
.
contentFilePath
).
to
.
be
.
equal
(
contentPath
)
expect
(
!!~
result1
.
devDeps
.
indexOf
(
contentPath
)).
to
.
be
.
equal
(
true
)
console
.
log
(
result1
)
})
})
packages/mvvm-interface-parser/test/getMethodCode.js
已删除
100644 → 0
浏览文件 @
84b1201e
const
getMethodCode
=
require
(
'
../lib/getMethodCode.js
'
);
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
const
interfacePath
=
path
.
join
(
__dirname
,
'
./lib/components/second/second.interface
'
);
const
content
=
fs
.
readFileSync
(
interfacePath
,
{
encoding
:
'
utf-8
'
})
let
result1
=
getMethodCode
({
interfacePath
,
content
,
cmlType
:
'
web
'
,
resolve
:
function
(
filePath
,
relativePath
)
{
return
path
.
resolve
(
path
.
dirname
(
filePath
),
relativePath
)
}});
console
.
log
(
result1
.
devDeps
)
packages/mvvm-interface-parser/test/getMethodCode.test.js
0 → 100644
浏览文件 @
079774ea
const
expect
=
require
(
'
chai
'
).
expect
;
const
getMethodCode
=
require
(
'
../lib/getMethodCode.js
'
);
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
const
cmlUtils
=
require
(
'
chameleon-tool-utils
'
)
describe
(
'
mvvm-interface-parser/getMethodCode
'
,
function
()
{
it
(
'
getMethodCode
'
,
function
()
{
const
interfacePath
=
path
.
join
(
__dirname
,
'
./lib/components/second/second.interface
'
);
const
content
=
fs
.
readFileSync
(
interfacePath
,
{
encoding
:
'
utf-8
'
})
let
result1
=
getMethodCode
({
interfacePath
,
content
,
cmlType
:
'
web
'
,
resolve
:
cmlUtils
.
resolveSync
});
let
firstInterfacePath
=
path
.
join
(
__dirname
,
'
./lib/components/first/first.interface
'
);
expect
(
result1
.
contentFilePath
).
to
.
be
.
equal
(
firstInterfacePath
)
expect
(
!!~
result1
.
devDeps
.
indexOf
(
firstInterfacePath
)).
to
.
be
.
equal
(
true
)
expect
(
!!~
result1
.
content
.
indexOf
(
'
FirstInterface
'
)).
to
.
be
.
equal
(
true
);
})
it
(
'
getMethodCode src
'
,
function
()
{
const
interfacePath
=
path
.
join
(
__dirname
,
'
./lib/components/third.interface
'
);
const
content
=
fs
.
readFileSync
(
interfacePath
,
{
encoding
:
'
utf-8
'
})
let
result1
=
getMethodCode
({
interfacePath
,
content
,
cmlType
:
'
weex
'
,
resolve
:
cmlUtils
.
resolveSync
});
let
contentPath
=
path
.
join
(
__dirname
,
'
./lib/components/thirdmethod.js
'
);
expect
(
result1
.
contentFilePath
).
to
.
be
.
equal
(
contentPath
)
expect
(
!!~
result1
.
devDeps
.
indexOf
(
contentPath
)).
to
.
be
.
equal
(
true
)
expect
(
!!~
result1
.
content
.
indexOf
(
'
thirdmethods
'
)).
to
.
be
.
equal
(
true
);
})
})
packages/mvvm-interface-parser/test/lib/components/third.interface
0 → 100644
浏览文件 @
079774ea
<script cml-type="interface" src="./thirdinterface.js"></script>
<script cml-type="web">
import test1 from './test1.js';
const requireModule = require('./test1.js');
import cml from 'chameleon-api';
class Method implements FirstInterface {
getMsg(msg) {
return 'first web:' + msg;
}
}
export default new Method();
</script>
<script cml-type="weex" src="./thirdmethod.js">
</script>
packages/mvvm-interface-parser/test/lib/components/thirdinterface.js
0 → 100644
浏览文件 @
079774ea
`interface FirstInterface {
getMsg(msg: String): String;
}`
packages/mvvm-interface-parser/test/lib/components/thirdmethod.js
0 → 100644
浏览文件 @
079774ea
`thirdmethods`
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录