Skip to content

Commit

Permalink
Add test to ensure that isomorphic rendering works both with and with…
Browse files Browse the repository at this point in the history
…out jsdom
  • Loading branch information
Robert-Frampton authored and Robert-Frampton committed Nov 14, 2017
1 parent be849c1 commit 26618ed
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/metal-isomorphic/test/isomorphic.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import Component from 'metal-component';
import MyComponent from './fixtures/MyComponent';
import MyJSXComponent from './fixtures/MyJSXComponent';
import jsdomGlobal from 'jsdom-global';
import { assert } from 'chai';

describe('Isomorphic Rendering', () => {
it('should render soy component to string', () => {
assert.ok(!global.document);

const htmlString = Component.renderToString(MyComponent, {
message: 'Hello, Soy!'
});
Expand All @@ -13,10 +16,44 @@ describe('Isomorphic Rendering', () => {
});

it('should render jsx component to string', () => {
assert.ok(!global.document);

const htmlString = Component.renderToString(MyJSXComponent, {
message: 'Hello, JSX!'
});

assert.equal(htmlString, '<div>Hello, JSX!</div>');
});

describe('JSDom', () => {
let cleanup;

before(() => {
cleanup = jsdomGlobal();
});

after(() => {
cleanup();
});

it('should render soy component to string', () => {
assert.ok(document);

const htmlString = Component.renderToString(MyComponent, {
message: 'Hello, Soy!'
});

assert.equal(htmlString, '<div>Hello, Soy!</div>');
});

it('should render jsx component to string', () => {
assert.ok(document);

const htmlString = Component.renderToString(MyJSXComponent, {
message: 'Hello, JSX!'
});

assert.equal(htmlString, '<div>Hello, JSX!</div>');
});
});
});

0 comments on commit 26618ed

Please sign in to comment.