forked from syrjs/core
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request syrjs#121 from MSiddharthReddy/jsxmodNrendertargets
Jsx Mod nd Render Targets for web raster
- Loading branch information
Showing
12 changed files
with
146 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Component, Render, RasterManager, View, Text } from '../index'; | ||
const assert = require('assert'); | ||
|
||
describe('JSX', function() { | ||
describe('Comments', function() { | ||
it('should not include comments in children', function() { | ||
class MyComponent extends Component { | ||
render() { | ||
return <View> | ||
{/*These are comments*/} | ||
<View/> | ||
{/*These are comments*/} | ||
<Text> Hello </Text> | ||
{/*These are comments*/} | ||
</View>; | ||
} | ||
} | ||
|
||
const mycomponent = new MyComponent(); | ||
const rendering = mycomponent.render(); | ||
|
||
assert.equal(typeof rendering.elementName, 'function'); | ||
assert.equal(typeof rendering.attributes, 'object'); | ||
assert.equal(rendering.children instanceof Array, true); | ||
assert.equal(rendering.children.length, 2); | ||
assert.equal(typeof rendering.guid, 'string'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Component, Render, RasterManager, Text } from '../index'; | ||
const assert = require('assert'); | ||
const initHTML = `<!DOCTYPE html><body><div id="root"></div></body></html>`; | ||
|
||
|
||
// including JSDOM to test browser rendering. | ||
require('./testsetup').testDom(initHTML); | ||
const HTMLSpanElement = window.HTMLSpanElement; | ||
|
||
|
||
describe('Render Target', function() { | ||
class RenderTargetTest extends Component { | ||
render() { | ||
return <Text className="foo" style={{height: 50, width: 100}}>Hello World</Text>; | ||
} | ||
} | ||
|
||
Render(RenderTargetTest, 'root'); | ||
const element = document.getElementById('root').children[0]; | ||
|
||
it('should render the given element as a child to the target', function() { | ||
assert.equal(element.style['height'], '50px'); | ||
assert.equal(element.style['width'], '100px'); | ||
assert.equal(element.innerText, 'Hello World'); | ||
}); | ||
|
||
|
||
}); | ||
describe('Render className', function() { | ||
class RenderClassNameTest extends Component { | ||
render() { | ||
return <Text className="foo" style={{height: 50, width: 100}}>Hello World</Text>; | ||
} | ||
} | ||
|
||
Render(RenderClassNameTest); | ||
//selecting the element with the given className | ||
const element = document.querySelector('.foo'); | ||
|
||
it('should render the given element with the given class', function() { | ||
assert.equal(element instanceof HTMLElement, true); | ||
assert.equal(element instanceof HTMLSpanElement, true); | ||
assert.equal(element.innerText, 'Hello World'); | ||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component, Render, RasterManager, Text } from '../index'; | ||
const assert = require('assert'); | ||
const initHTML = `<!DOCTYPE html><body></body></html>`; | ||
|
||
// including JSDOM to test browser rendering. | ||
require('./testsetup').testDom(initHTML); | ||
|
||
|
||
describe('Text View', function() { | ||
class TextTest extends Component { | ||
render() { | ||
return <Text style={{height: 50, width: 100}}>Hello World</Text>; | ||
} | ||
} | ||
|
||
Render(TextTest); | ||
//since the text view is rendered in a span. | ||
const element = document.querySelector('span'); | ||
|
||
it('should render text with the given styles', function() { | ||
assert.equal(element.style['height'], '50px'); | ||
assert.equal(element.style['width'], '100px'); | ||
assert.equal(element.innerText, 'Hello World'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters