-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1 * 2 * 3 * 4 * 5
- Loading branch information
Showing
6 changed files
with
271 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"use strict"; | ||
|
||
const React = require("react"); // eslint-disable-line | ||
const feLib = require("../../src"); | ||
const { JSDOM } = require("jsdom"); | ||
|
||
describe("FE React framework", function() { | ||
// | ||
it("should setup FrameworkLib", () => { | ||
expect(feLib.React).to.be.ok; | ||
expect(feLib.AppContext).to.be.ok; | ||
expect(feLib.loadSubApp).to.be.a("function"); | ||
expect(feLib.FrameworkLib).to.be.ok; | ||
}); | ||
|
||
it("should render component into DOM element", () => { | ||
const dom = new JSDOM(`<div id="test"></div>`); | ||
global.window = dom.window; | ||
const element = dom.window.document.getElementById("test"); | ||
const framework = new feLib.FrameworkLib({ | ||
subApp: { | ||
info: { | ||
Component: props => <p>hello {props.foo}</p> | ||
} | ||
}, | ||
element, | ||
options: { props: { foo: "bar" } } | ||
}); | ||
framework.renderStart(); | ||
expect(element.innerHTML).equals(`<p>hello bar</p>`); | ||
}); | ||
|
||
it("should hydrate render component into DOM element", () => { | ||
const dom = new JSDOM(`<div id="test"><p>hello <!-- -->bar</p></div>`); | ||
global.window = dom.window; | ||
const element = dom.window.document.getElementById("test"); | ||
const framework = new feLib.FrameworkLib({ | ||
subApp: { | ||
info: { | ||
Component: props => <p>hello {props.foo}</p> | ||
} | ||
}, | ||
element, | ||
options: { props: { foo: "bar" }, serverSideRendering: true } | ||
}); | ||
framework.renderStart(); | ||
expect(element.innerHTML).equals(`<p>hello <!-- -->bar</p>`); | ||
}); | ||
|
||
it("should just return the component without DOM element", () => { | ||
const Component = props => <p>hello {props.foo}</p>; | ||
|
||
const framework = new feLib.FrameworkLib({ | ||
subApp: { | ||
info: { Component } | ||
}, | ||
options: { props: { foo: "bar" }, serverSideRendering: true } | ||
}); | ||
const c = framework.renderStart(); | ||
expect(c.type).equals(Component); | ||
}); | ||
}); |
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