]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(compiler-dom): add DOM compiler integration compile test (#189)
authorCarlos Rodrigues <david-181@hotmail.com>
Fri, 11 Oct 2019 14:13:55 +0000 (15:13 +0100)
committerEvan You <yyx990803@gmail.com>
Fri, 11 Oct 2019 14:13:55 +0000 (10:13 -0400)
packages/compiler-dom/__tests__/__snapshots__/index.spec.ts.snap [new file with mode: 0644]
packages/compiler-dom/__tests__/index.spec.ts [new file with mode: 0644]

diff --git a/packages/compiler-dom/__tests__/__snapshots__/index.spec.ts.snap b/packages/compiler-dom/__tests__/__snapshots__/index.spec.ts.snap
new file mode 100644 (file)
index 0000000..e7f4cb0
--- /dev/null
@@ -0,0 +1,22 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`compile should contain standard transforms 1`] = `
+"const _Vue = Vue
+const _createVNode = Vue.createVNode
+
+const _hoisted_1 = {}
+
+return function render() {
+  with (this) {
+    const { createVNode: _createVNode, createBlock: _createBlock, Fragment: _Fragment, openBlock: _openBlock } = _Vue
+    
+    return (_openBlock(), _createBlock(_Fragment, null, [
+      _createVNode(\\"div\\", { textContent: text }, null, 8 /* PROPS */, [\\"textContent\\"]),
+      _createVNode(\\"div\\", { innerHTML: html }, null, 8 /* PROPS */, [\\"innerHTML\\"]),
+      _createVNode(\\"div\\", null, \\"test\\"),
+      _createVNode(\\"div\\", { style: _hoisted_1 }, \\"red\\", 4 /* STYLE */),
+      _createVNode(\\"div\\", { style: {color: 'green'}}, null, 4 /* STYLE */)
+    ]))
+  }
+}"
+`;
diff --git a/packages/compiler-dom/__tests__/index.spec.ts b/packages/compiler-dom/__tests__/index.spec.ts
new file mode 100644 (file)
index 0000000..d40bf36
--- /dev/null
@@ -0,0 +1,13 @@
+import { compile } from '../src'
+
+describe('compile', () => {
+  it('should contain standard transforms', () => {
+    const { code } = compile(`<div v-text="text"></div>
+        <div v-html="html"></div>
+        <div v-cloak>test</div>
+        <div style="color=red">red</div>
+        <div :style="{color: 'green'}"></div>`)
+
+    expect(code).toMatchSnapshot()
+  })
+})