forked from princejwesley/Mancy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be9b0d4
commit b0726f3
Showing
15 changed files
with
286 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: node_js | ||
node_js: | ||
- "4.1" | ||
- "4.0" | ||
- "0.12" | ||
- "0.11" | ||
- "0.10" | ||
- "iojs" | ||
#before_script: | ||
# - npm install -g gulp | ||
#script: gulp |
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
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,8 @@ | ||
|
||
module.exports = { | ||
writeText: jest.genMockFunction(), | ||
readText: jest.genMockFunction(), | ||
readHTML: jest.genMockFunction(), | ||
writeHTML: jest.genMockFunction(), | ||
clear: jest.genMockFunction() | ||
}; |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
module.exports = { beep: jest.genMockFunction() } | ||
module.exports = { beep: jest.genMockFunction() }; |
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,24 @@ | ||
|
||
jest.dontMock('../ReplEntries.js'); | ||
jest.dontMock('../ReplEntry.js'); | ||
jest.dontMock('md5'); | ||
|
||
describe('ReplEntries', () => { | ||
let React = require('react/addons'); | ||
let ReplEntries = require('../ReplEntries.js'); | ||
let TestUtils = React.addons.TestUtils; | ||
let entries = [{ | ||
formattedOutput: '<span class="literal"> undefined </span>', | ||
plainCode: 'let name = "mancy"', | ||
status: true, | ||
command: '<span class="literal">let</span> name = <span class="string">"mancy"</span>' | ||
}]; | ||
|
||
it('should rendered properly', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplEntries entries={entries} /> | ||
); | ||
let children = TestUtils.scryRenderedDOMComponentsWithClass(component, 'repl-entry'); | ||
expect(children.length).toBe(entries.length); | ||
}); | ||
}); |
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,55 @@ | ||
import ReplActions from '../../actions/ReplActions'; | ||
|
||
jest.dontMock('../ReplEntry.js'); | ||
jest.dontMock('../ReplEntryIcon.js'); | ||
jest.dontMock('../ReplEntryStatus.js'); | ||
|
||
describe('ReplEntry', () => { | ||
let React = require('react/addons'); | ||
let ReplEntry = require('../ReplEntry.js'); | ||
let TestUtils = React.addons.TestUtils; | ||
let entry = { | ||
formattedOutput: '<span class="literal"> undefined </span>', | ||
plainCode: 'let name = "mancy"', | ||
status: true, | ||
command: '<span class="literal">let</span> name = <span class="string">"mancy"</span>' | ||
}; | ||
|
||
it('should collapse', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplEntry log={entry} index={0} key={Date.now}/> | ||
); | ||
let icon = TestUtils.findRenderedDOMComponentWithClass(component, 'repl-entry-icon'); | ||
let action = TestUtils.findRenderedDOMComponentWithTag(icon, 'i'); | ||
TestUtils.Simulate.click(action); | ||
expect(ReplActions.toggleCommandEntryView).toBeCalled(); | ||
}); | ||
|
||
it('should toggle entry', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplEntry log={entry} index={0} key={Date.now}/> | ||
); | ||
let icon = TestUtils.findRenderedDOMComponentWithClass(component, 'fa fa-minus-circle'); | ||
TestUtils.Simulate.click(icon); | ||
expect(ReplActions.toggleEntryView).toBeCalled(); | ||
}); | ||
|
||
it('should remove', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplEntry log={entry} index={0} key={Date.now}/> | ||
); | ||
let icon = TestUtils.findRenderedDOMComponentWithClass(component, 'fa-times-circle'); | ||
TestUtils.Simulate.click(icon); | ||
expect(ReplActions.removeEntry).toBeCalled(); | ||
}); | ||
|
||
it('should reload prompt', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplEntry log={entry} index={0} key={Date.now}/> | ||
); | ||
let icon = TestUtils.findRenderedDOMComponentWithClass(component, 'repeat'); | ||
TestUtils.Simulate.click(icon); | ||
expect(ReplActions.reloadPrompt).toBeCalled(); | ||
}); | ||
|
||
}); |
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,33 @@ | ||
|
||
jest.dontMock('../ReplEntryOutputError.js'); | ||
|
||
describe('ReplEntryOutputError', () => { | ||
let React = require('react/addons'); | ||
let ReplEntryOutputError = require('../ReplEntryOutputError.js'); | ||
let TestUtils = React.addons.TestUtils; | ||
let error = 'name is not defined'; | ||
let errorFile = 'repl.js'; | ||
let errorFunction = 'REPLServer.defaultEval'; | ||
let errorLine = '166'; | ||
let errorColumn = '27'; | ||
let msg = `ReferenceError: ${error}`; | ||
let trace = [`at ${errorFunction} (${errorFile}:${errorLine}:${errorColumn})`]; | ||
|
||
it('should rendered properly', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplEntryOutputError message={msg} trace={trace}> | ||
</ReplEntryOutputError> | ||
); | ||
let errorMsg = TestUtils.findRenderedDOMComponentWithClass(component, 'repl-entry-output-error-message'); | ||
let errorTraceFile = TestUtils.findRenderedDOMComponentWithClass(component, 'stack-error-file'); | ||
let errorTraceFunction = TestUtils.findRenderedDOMComponentWithClass(component, 'stack-error-function'); | ||
let errorTraceLine = TestUtils.findRenderedDOMComponentWithClass(component, 'stack-error-row'); | ||
let errorTraceColumn = TestUtils.findRenderedDOMComponentWithClass(component, 'stack-error-column'); | ||
|
||
expect(React.findDOMNode(errorMsg).textContent).toContain(error); | ||
expect(React.findDOMNode(errorTraceFile).textContent).toContain(errorFile); | ||
expect(React.findDOMNode(errorTraceFunction).textContent).toContain(errorFunction); | ||
expect(React.findDOMNode(errorTraceLine).textContent).toContain(errorLine); | ||
expect(React.findDOMNode(errorTraceColumn).textContent).toContain(errorColumn); | ||
}); | ||
}); |
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,36 @@ | ||
|
||
jest.dontMock('../ReplOutputArray.js'); | ||
jest.dontMock('../../common/ReplOutput.js'); | ||
|
||
describe('ReplOutputArray', () => { | ||
let React = require('react/addons'); | ||
let ReplOutputArray = require('../ReplOutputArray.js'); | ||
let TestUtils = React.addons.TestUtils; | ||
let label = 'Array[7]'; | ||
let arr = [0, true, 'yes', null, undefined, [1], {fun: () => {}}]; | ||
|
||
it('should have collapsed array', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplOutputArray array={arr} label={label} start={0} noIndex={false}/> | ||
); | ||
|
||
let desc = TestUtils.findRenderedDOMComponentWithClass(component, 'array-desc'); | ||
expect(React.findDOMNode(desc).textContent).toEqual(label); | ||
let entry = TestUtils.scryRenderedDOMComponentsWithClass(component, 'array-entry'); | ||
expect(entry.length).toBe(0); | ||
}); | ||
|
||
it('should expand array', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplOutputArray array={arr} label={label} start={0} noIndex={false}/> | ||
); | ||
|
||
let icon = TestUtils.findRenderedDOMComponentWithClass(component, 'fa-play'); | ||
TestUtils.Simulate.click(icon); | ||
jest.runAllTicks(); | ||
|
||
let entries = TestUtils.scryRenderedDOMComponentsWithClass(component, 'array-entry'); | ||
expect(entries.length).toBe(arr.length); | ||
}); | ||
|
||
}); |
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,63 @@ | ||
|
||
jest.dontMock('../ReplOutputFunction.js'); | ||
jest.dontMock('../../common/ReplOutput.js'); | ||
|
||
describe('ReplOutputFunction', () => { | ||
let React = require('react/addons'); | ||
let ReplOutputFunction = require('../ReplOutputFunction.js'); | ||
let TestUtils = React.addons.TestUtils; | ||
let label = ' function() {}'; | ||
let f = function test() { | ||
return 'test'; | ||
}; | ||
f.desc = 'testMe'; | ||
let funElement = ` | ||
<span class='literal'>function</span><span> test() { | ||
<span class='literal'>return</span> <span class='string'> 'test'</span>; | ||
} | ||
</span> | ||
`; | ||
let shortElement = ` | ||
<span class='literal'>function</span><span> test() { | ||
</span> | ||
`; | ||
|
||
it('should have collapsed function', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplOutputFunction html={funElement} fun={f} expandable={false} short={shortElement}/> | ||
); | ||
|
||
let desc = TestUtils.findRenderedDOMComponentWithClass(component, 'object-desc'); | ||
expect(React.findDOMNode(desc).textContent).toEqual(label); | ||
let entry = TestUtils.scryRenderedDOMComponentsWithClass(component, 'object-entry'); | ||
expect(entry.length).toBe(0); | ||
}); | ||
|
||
it('should expand function', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplOutputFunction html={funElement} fun={f} expandable={false} short={shortElement}/> | ||
); | ||
|
||
let icon = TestUtils.findRenderedDOMComponentWithClass(component, 'fa-play'); | ||
TestUtils.Simulate.click(icon); | ||
jest.runAllTicks(); | ||
|
||
let entries = TestUtils.scryRenderedDOMComponentsWithClass(component, 'object-entry'); | ||
expect(entries.length).toBe(Object.keys(f).length); | ||
}); | ||
|
||
it('should expand function source', () => { | ||
let component = TestUtils.renderIntoDocument( | ||
<ReplOutputFunction html={funElement} fun={f} expandable={true} short={shortElement}/> | ||
); | ||
|
||
let icon = TestUtils.findRenderedDOMComponentWithClass(component, 'fa-play'); | ||
TestUtils.Simulate.click(icon); | ||
jest.runAllTicks(); | ||
let source = TestUtils.findRenderedDOMComponentWithClass(component, 'fa-plus-square-o'); | ||
TestUtils.Simulate.click(source); | ||
jest.runAllTicks(); | ||
TestUtils.scryRenderedDOMComponentsWithClass(component, 'fa-minus-square-o'); | ||
}); | ||
|
||
}); |
Oops, something went wrong.