-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
14 changed files
with
112 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_js: | |
- "4" | ||
- "5" | ||
- "6" | ||
script: npm run check |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,5 @@ | ||
{ | ||
"rules": { | ||
"import/no-extraneous-dependencies": [2, {"devDependencies": true}] | ||
} | ||
} |
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,52 @@ | ||
import React from 'react'; | ||
import td from 'testdouble'; | ||
import test from 'ava'; | ||
import { mount, shallow } from 'enzyme'; | ||
|
||
const hjs = td.replace('highlight.js'); | ||
const Highlight = require('../../src/components/Highlight').default; | ||
|
||
test.cb('no language - calls correct highlightCall', t => { | ||
td | ||
.when(hjs.highlightAuto('test', undefined)) | ||
.thenReturn({ value: 'othertest', language: 'xml' }); | ||
const wrapper = mount(<Highlight>test</Highlight>); | ||
|
||
setTimeout(() => { | ||
t.is(wrapper.state('language'), 'xml'); | ||
t.is(wrapper.state('highlightedCode'), 'othertest'); | ||
t.end(); | ||
}, 1); | ||
}); | ||
|
||
test.cb('one language - calls correct highlightCall', t => { | ||
td | ||
.when(hjs.highlight('js', 'test')) | ||
.thenReturn({ value: 'othertest', language: 'js' }); | ||
const wrapper = mount(<Highlight languages={['js']}>test</Highlight>); | ||
|
||
setTimeout(() => { | ||
t.is(wrapper.state('language'), 'js'); | ||
t.is(wrapper.state('highlightedCode'), 'othertest'); | ||
t.end(); | ||
}, 1); | ||
}); | ||
|
||
test.cb('multiple languages - calls correct highlightCall', t => { | ||
td | ||
.when(hjs.highlightAuto('test', ['js', 'html'])) | ||
.thenReturn({ value: 'othertest', language: 'js' }); | ||
const wrapper = mount(<Highlight languages={['js', 'html']}>test</Highlight>); | ||
|
||
setTimeout(() => { | ||
t.is(wrapper.state('language'), 'js'); | ||
t.is(wrapper.state('highlightedCode'), 'othertest'); | ||
t.end(); | ||
}, 1); | ||
}); | ||
|
||
test('className is passed through', t => { | ||
const wrapper = shallow(<Highlight className="foobar">test</Highlight>); | ||
|
||
t.true(wrapper.childAt(0).hasClass('foobar')); | ||
}); |
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,3 @@ | ||
global.document = require('jsdom').jsdom('<body></body>'); | ||
global.window = document.defaultView; | ||
global.navigator = window.navigator; |
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 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import test from 'ava'; | ||
import Highlight from '../src/index'; | ||
|
||
test('exports default component', t => { | ||
t.notThrows(() => shallow(<Highlight>test</Highlight>)); | ||
}); |
This file was deleted.
Oops, something went wrong.