From 38acabfa6089ab8ac469c12b5f55022fb96935e5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 23 Aug 2021 16:46:06 -0300 Subject: added web vendors --- preact/debug/test/browser/serializeVNode.test.js | 66 ++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 preact/debug/test/browser/serializeVNode.test.js (limited to 'preact/debug/test/browser/serializeVNode.test.js') diff --git a/preact/debug/test/browser/serializeVNode.test.js b/preact/debug/test/browser/serializeVNode.test.js new file mode 100644 index 0000000..f8c8515 --- /dev/null +++ b/preact/debug/test/browser/serializeVNode.test.js @@ -0,0 +1,66 @@ +import { createElement, Component } from 'preact'; +import { serializeVNode } from '../../src/debug'; + +/** @jsx createElement */ + +describe('serializeVNode', () => { + it("should prefer a function component's displayName", () => { + function Foo() { + return
; + } + Foo.displayName = 'Bar'; + + expect(serializeVNode()).to.equal(''); + }); + + it("should prefer a class component's displayName", () => { + class Bar extends Component { + render() { + return
; + } + } + Bar.displayName = 'Foo'; + + expect(serializeVNode()).to.equal(''); + }); + + it('should serialize vnodes without children', () => { + expect(serializeVNode(
)).to.equal('
'); + }); + + it('should serialize vnodes with children', () => { + expect(serializeVNode(
Hello World
)).to.equal('
..
'); + }); + + it('should serialize components', () => { + function Foo() { + return
; + } + expect(serializeVNode()).to.equal(''); + }); + + it('should serialize props', () => { + expect(serializeVNode(
)).to.equal('
'); + + // Ensure that we have a predictable function name. Our test runner + // creates an all inclusive bundle per file and the identifier + // "noop" may have already been used. + // eslint-disable-next-line func-style + let noop = function noopFn() {}; + expect(serializeVNode(
)).to.equal( + '
' + ); + + function Foo(props) { + return props.foo; + } + + expect(serializeVNode()).to.equal( + '' + ); + + expect(serializeVNode(
)).to.equal( + '
' + ); + }); +}); -- cgit v1.2.3