add some specs
diff --git a/test/expect/m.js b/test/expect/m.js
new file mode 100644
index 0000000..49cc599
--- /dev/null
+++ b/test/expect/m.js
@@ -0,0 +1,27 @@
+{
+ "@weex-component/toast": {},
+ "@weex-component/7c847f2d41c5dec61fa7b99a8ec828c7": {
+ "ready": "function ready() {\n\t toast(this.name);\n\t }",
+ "data": "function data() {\n\t return {\n\t name: 'Weex'\n\t };\n\t }",
+ "template": {
+ "type": "div",
+ "children": [
+ {
+ "type": "text",
+ "classList": [
+ "hello"
+ ],
+ "attr": {
+ "value": "function () {return 'Hello ' + (this.name)}"
+ }
+ }
+ ]
+ },
+ "style": {
+ "hello": {
+ "fontSize": 26,
+ "color": "#FF0000"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/spec/m.we b/test/spec/m.we
new file mode 100644
index 0000000..b7c5ddc
--- /dev/null
+++ b/test/spec/m.we
@@ -0,0 +1,29 @@
+<template>
+ <div>
+ <text class="hello">Hello {{name}}</text>
+ </div>
+</template>
+
+
+<style>
+.hello {
+ font-size: 26px;
+ color: red;
+}
+</style>
+
+
+<script>
+var toast = require('./toast.js')
+
+module.exports = {
+ ready: function() {
+ toast(this.name)
+ },
+ data: function() {
+ return {
+ name: 'Weex'
+ }
+ }
+}
+</script>
\ No newline at end of file
diff --git a/test/spec/toast.js b/test/spec/toast.js
new file mode 100644
index 0000000..af59d1b
--- /dev/null
+++ b/test/spec/toast.js
@@ -0,0 +1,8 @@
+var modal
+__weex_define__('@weex-component/toast', [], function(__weex_require__) {
+ modal = __weex_require__('@weex-module/modal')
+})
+
+module.exports = function(msg) {
+ modal.toast({message: msg})
+}
\ No newline at end of file
diff --git a/test/test.js b/test/test.js
index 6725fe2..5f08344 100644
--- a/test/test.js
+++ b/test/test.js
@@ -108,7 +108,7 @@
expect(bootstrapStub.firstCall.args[2]).is.not.undefined;
});
- it('template and require weex modules', () => {
+ it('template and use weex module', () => {
expectActual('j');
expect(requireStub.callCount).eql(1);
expect(requireStub.firstCall.args).eql(['@weex-module/modal']);
@@ -120,8 +120,15 @@
expect(requireStub.firstCall.args).eql(['@weex-module/modal']);
});
- it('template and require commonjs modules', () => {
+ it('template and require commonjs module', () => {
expectActual('l');
expect(requireStub.callCount).eql(1);
+ expect(requireStub.firstCall.args).eql(['@weex-module/modal']);
+ });
+
+ it('template and use weex module in commonjs module', () => {
+ expectActual('m');
+ expect(requireStub.callCount).eql(1);
+ expect(requireStub.firstCall.args).eql(['@weex-module/modal']);
});
})
diff --git a/test/webpack.config.js b/test/webpack.config.js
index 5c58603..a72fd6d 100644
--- a/test/webpack.config.js
+++ b/test/webpack.config.js
@@ -3,7 +3,7 @@
var entry = {}
var start = 'a'
-var end = 'l'
+var end = 'm'
var count = end.charCodeAt(0) - start.charCodeAt(0)
new Array(count + 1).fill(0)