forked from instructure-react/react-tinymce
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(testing): added a bunch of tests
related to instructure-react#65
- Loading branch information
Jan Stümmel
committed
Jun 13, 2017
1 parent
c01162f
commit 6b27ab0
Showing
9 changed files
with
234 additions
and
17 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,3 @@ | ||
{ | ||
"presets": [ "react", "es2015" ] | ||
} |
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,53 @@ | ||
module.exports = function(config) { | ||
config.set({ | ||
|
||
basePath: '', | ||
|
||
frameworks: [ | ||
'mocha', | ||
'browserify', | ||
'chai' | ||
], | ||
|
||
files: [ | ||
|
||
// tinymce | ||
'node_modules/tinymce/tinymce.min.js', | ||
'node_modules/tinymce/plugins/**/*.min.js', | ||
'node_modules/tinymce/themes/**/*.min.js', | ||
{ pattern: 'node_modules/tinymce/skins/**', watched: false, included: false }, | ||
|
||
// tests | ||
'test/**/*Spec.js', | ||
], | ||
|
||
exclude: [ | ||
], | ||
|
||
preprocessors: { | ||
'test/**/*Spec.js': [ 'browserify' ] | ||
}, | ||
|
||
reporters: ['spec'], | ||
|
||
port: 9876, | ||
|
||
colors: true, | ||
|
||
logLevel: config.LOG_INFO, | ||
|
||
autoWatch: true, | ||
|
||
browsers: ['PhantomJS'], | ||
|
||
singleRun: false, | ||
|
||
concurrency: Infinity, | ||
|
||
// browserify configuration | ||
browserify: { | ||
debug: true, | ||
transform: [ [ 'babelify' ] ] | ||
} | ||
}) | ||
} |
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,36 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import domify from 'domify'; | ||
import TestContainer from 'mocha-test-container-support'; | ||
|
||
import TinyMCE from '../'; | ||
|
||
describe('TinyMCE component tests', () => { | ||
|
||
var testContainer; | ||
|
||
beforeEach( function () { | ||
testContainer = TestContainer.get(this); | ||
}); | ||
|
||
|
||
it('should render TinyMCE Component', () => { | ||
|
||
ReactDOM.render(<TinyMCE config={{}} />, testContainer); | ||
}); | ||
|
||
|
||
it('should render TinyMCE Component inline', () => { | ||
|
||
var div = document.createElement('div'); | ||
testContainer.appendChild(div); | ||
|
||
ReactDOM.render( | ||
<TinyMCE config={{ inline: true }} content="<strong>Hello World</strong>"/>, | ||
div | ||
); | ||
}); | ||
|
||
|
||
}); |
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,50 @@ | ||
const domify = require('domify'); | ||
const TestContainer = require('mocha-test-container-support'); | ||
|
||
describe('basic test with global tinymce', () => { | ||
|
||
var testContainer; | ||
|
||
beforeEach( function () { | ||
testContainer = TestContainer.get(this); | ||
}); | ||
|
||
|
||
it('should be defined', () => { | ||
|
||
// when | ||
var tm = global.tinymce | ||
|
||
// then | ||
expect(tm).to.be.not.undefined | ||
}); | ||
|
||
|
||
it('should tinymceify textarea', () => { | ||
|
||
// given | ||
testContainer.appendChild(document.createElement('textarea')); | ||
|
||
// when | ||
tinymce.init({ selector: 'textarea' }); | ||
|
||
// then | ||
expect(testContainer.childNodes[0].className).to.include('mce-tinymce'); | ||
}); | ||
|
||
|
||
it('should tinymceify textarea inline', () => { | ||
|
||
// given | ||
const div = domify('<div id="inline">Hello World</div>') | ||
testContainer.appendChild(div); | ||
|
||
// when | ||
tinymce.init({ selector: '#inline', inline: true }); | ||
|
||
// then | ||
expect(div.contentEditable).to.equal('true'); | ||
expect(div.innerHTML).to.equal('<p>Hello World</p>'); | ||
}); | ||
|
||
}); |
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 @@ | ||
const React = require('react'); | ||
var test = React.createClass({ | ||
render: function(){ return null; } | ||
}); | ||
module.exports = Test; |
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,6 @@ | ||
const React = require('react'); | ||
class Test extends React.Component { | ||
render() { return null; } | ||
} | ||
Test.propTypes = { foo: React.PropTypes.string }; | ||
module.exports = Test; |
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 @@ | ||
|
||
describe('createClass/PropTypes Error', () => { | ||
|
||
var warn; | ||
|
||
before(() => { | ||
// let console.warn throw an error | ||
warn = console.warn; | ||
console.warn = (msg) => { throw new Error(msg); | ||
}}); | ||
|
||
after(() => console.warn = warn); | ||
|
||
|
||
it('should throw PropTypes Warning', () => { | ||
|
||
expect(() => { | ||
|
||
// when | ||
var BadPropTypesTest = require('./fixtures/badPropTypes'); | ||
}) | ||
|
||
// then | ||
.to.throw(/^Warning: Accessing PropTypes via the main React/); | ||
|
||
}); | ||
|
||
|
||
it('should throw createClass Warning', () => { | ||
|
||
expect(() => { | ||
|
||
// when | ||
var BadPropTypesTest = require('./fixtures/badCreateClass'); | ||
}) | ||
|
||
// then | ||
.to.throw(/^Warning: Accessing createClass via the main React/); | ||
|
||
}); | ||
|
||
|
||
it('should should not throw creatClass or PropTypes Warning', () => { | ||
|
||
expect(() => { | ||
|
||
// when | ||
var TinyMCE = require('../') | ||
}) | ||
|
||
// then | ||
.to.not.throw(); | ||
}); | ||
|
||
}); |