diff --git a/packages/rax-server-renderer/package.json b/packages/rax-server-renderer/package.json index ff55b355c2..1977bad4dd 100644 --- a/packages/rax-server-renderer/package.json +++ b/packages/rax-server-renderer/package.json @@ -1,6 +1,6 @@ { "name": "rax-server-renderer", - "version": "1.1.2", + "version": "1.1.3", "description": "Rax renderer for server-side render.", "license": "BSD-3-Clause", "main": "lib/index.js", diff --git a/packages/rax-server-renderer/src/__tests__/attributes.js b/packages/rax-server-renderer/src/__tests__/attributes.js new file mode 100644 index 0000000000..210dadc484 --- /dev/null +++ b/packages/rax-server-renderer/src/__tests__/attributes.js @@ -0,0 +1,782 @@ +/* @jsx createElement */ + +import {createElement} from 'rax'; +import {renderToString} from '../index'; + +describe('renderToString', () => { + describe('property to attribute mapping', function() { + describe('string properties', function() { + it('simple numbers ', () => { + function MyComponent() { + return
; + } + + const str = renderToString(); + expect(str).toBe('
'); + }); + + it('simple strings ', () => { + function MyComponent() { + return
; + } + + const str = renderToString(); + expect(str).toBe('
'); + }); + + it('no string prop with true value', () => { + function MyComponent() { + return ; + } + + const str = renderToString(); + expect(str).toBe(''); + }); + + it('no string prop with false value', () => { + function MyComponent() { + return ; + } + + const str = renderToString(); + expect(str).toBe(''); + }); + + it('no string prop with null value', () => { + function MyComponent() { + return
; + } + + const str = renderToString(); + expect(str).toBe('
'); + }); + + it('no string prop with function value', () => { + let fun = function() {}; + + function MyComponent() { + return
; + } + + const str = renderToString(); + expect(str).toBe('
'); + }); + + it('no string prop with symbol value', () => { + function MyComponent() { + return
; + } + + const str = renderToString(); + expect(str).toBe('
'); + }); + }); + + describe('boolean properties', function() { + it('boolean prop with true value', () => { + function MyComponent() { + return