From: hareku Date: Mon, 9 Mar 2020 21:08:05 +0000 (+0900) Subject: test(runtime-core/renderer): tests for rendering elements (#699) X-Git-Tag: v3.0.0-alpha.9~46 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e12ddd96bae9bee896b9e2f97f5d7c1d09c61868;p=thirdparty%2Fvuejs%2Fcore.git test(runtime-core/renderer): tests for rendering elements (#699) --- diff --git a/packages/runtime-core/__tests__/rendererElement.spec.ts b/packages/runtime-core/__tests__/rendererElement.spec.ts index ffab39f5ef..4e044ad408 100644 --- a/packages/runtime-core/__tests__/rendererElement.spec.ts +++ b/packages/runtime-core/__tests__/rendererElement.spec.ts @@ -1,9 +1,51 @@ +import { + h, + render, + nodeOps, + TestElement, + serializeInner as inner +} from '@vue/runtime-test' + describe('renderer: element', () => { - test.todo('with props') + let root: TestElement + + beforeEach(() => { + root = nodeOps.createElement('div') + }) + + it('should create an element', () => { + render(h('div'), root) + expect(inner(root)).toBe('
') + }) + + it('should create an element with props', () => { + render(h('div', { id: 'foo', class: 'bar' }), root) + expect(inner(root)).toBe('
') + }) + + it('should create an element with direct text children', () => { + render(h('div', ['foo', ' ', 'bar']), root) + expect(inner(root)).toBe('
foo bar
') + }) + + it('should create an element with direct text children and props', () => { + render(h('div', { id: 'foo' }, ['bar']), root) + expect(inner(root)).toBe('
bar
') + }) + + it('should update an element tag which is already mounted', () => { + render(h('div', ['foo']), root) + expect(inner(root)).toBe('
foo
') - test.todo('with direct text children') + render(h('span', ['foo']), root) + expect(inner(root)).toBe('foo') + }) - test.todo('with text node children') + it('should update element props which is already mounted', () => { + render(h('div', { id: 'bar' }, ['foo']), root) + expect(inner(root)).toBe('
foo
') - test.todo('handle already mounted VNode') + render(h('div', { id: 'baz', class: 'bar' }, ['foo']), root) + expect(inner(root)).toBe('
foo
') + }) })