From 6d9a7e90f57d98480ae716d81752a5cc0c5b1a46 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Tue, 6 Mar 2018 10:11:04 +0000 Subject: [PATCH] Add simple fixtures support --- .../test/unit_frontend/es/RichTextTests.js | 24 +++++++++++++++++++ .../test/unit_frontend/es/support/fixture.js | 17 +++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 services/web/test/unit_frontend/es/RichTextTests.js create mode 100644 services/web/test/unit_frontend/es/support/fixture.js diff --git a/services/web/test/unit_frontend/es/RichTextTests.js b/services/web/test/unit_frontend/es/RichTextTests.js new file mode 100644 index 0000000000..56d3be8d54 --- /dev/null +++ b/services/web/test/unit_frontend/es/RichTextTests.js @@ -0,0 +1,24 @@ +import CodeMirror from 'codemirror' + +import fixture from './support/fixture' + +const TEXTAREA_HTML = '' + +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') + }) +}) diff --git a/services/web/test/unit_frontend/es/support/fixture.js b/services/web/test/unit_frontend/es/support/fixture.js new file mode 100644 index 0000000000..38c71f1650 --- /dev/null +++ b/services/web/test/unit_frontend/es/support/fixture.js @@ -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