mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #383 from sharelatex/as-karma-fixtures
Add fixtures support to frontend tests
This commit is contained in:
commit
0d7ca1fc40
2 changed files with 41 additions and 0 deletions
24
services/web/test/unit_frontend/es/RichTextTests.js
Normal file
24
services/web/test/unit_frontend/es/RichTextTests.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import CodeMirror from 'codemirror'
|
||||
|
||||
import fixture from './support/fixture'
|
||||
|
||||
const TEXTAREA_HTML = '<textarea>Test</textarea>'
|
||||
|
||||
describe('fixtures', function () {
|
||||
beforeEach(function () {
|
||||
this.textarea = fixture.load(TEXTAREA_HTML)
|
||||
this.cm = CodeMirror.fromTextArea(this.textarea)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
fixture.cleanUp()
|
||||
})
|
||||
|
||||
it('loads fixtures', function () {
|
||||
expect(this.textarea.value).to.equal('Test')
|
||||
})
|
||||
|
||||
it('works with CM', function () {
|
||||
expect(this.cm.getValue()).to.equal('Test')
|
||||
})
|
||||
})
|
17
services/web/test/unit_frontend/es/support/fixture.js
Normal file
17
services/web/test/unit_frontend/es/support/fixture.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
class Fixture {
|
||||
constructor () {
|
||||
this.el = document.createElement('div')
|
||||
}
|
||||
|
||||
load (html) {
|
||||
this.el.innerHTML = html
|
||||
return this.el.firstChild
|
||||
}
|
||||
|
||||
cleanUp () {
|
||||
this.el.innerHTML = ''
|
||||
}
|
||||
}
|
||||
|
||||
const fixture = new Fixture()
|
||||
export default fixture
|
Loading…
Reference in a new issue