Skip to content

Commit 9efdfe7

Browse files
committed
Ticket #196 - Added tests
1 parent 2d9601a commit 9efdfe7

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

test/test.options.js

+67-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*global createContainer:false, removeContainer:false, rnd:false */
1+
/*global createContainer:false, removeContainer:false, rnd:false, getIframeDoc: false */
22

33
describe('EpicEditor([options])', function () {
44
var editor
@@ -112,4 +112,70 @@ describe('EpicEditor([options])', function () {
112112
.to.be('Qux');
113113
});
114114
});
115+
describe('options.theme', function () {
116+
beforeEach(function () {
117+
opts.theme = {};
118+
});
119+
describe('.base', function () {
120+
var editorStylesheet;
121+
it('should add the basePath path if the theme does not have an absolute link', function () {
122+
opts.theme.base = '/foo/';
123+
editor = new EpicEditor(opts).load();
124+
editorStylesheet = getIframeDoc(editor.getElement('wrapperIframe')).getElementById('theme');
125+
expect(editorStylesheet.href).to.contain('/epiceditor');
126+
});
127+
it('should NOT add the basePath path if the theme DOES have an absolute http link', function () {
128+
opts.theme.base = 'http://foo.com';
129+
editor = new EpicEditor(opts).load();
130+
editorStylesheet = getIframeDoc(editor.getElement('wrapperIframe')).getElementById('theme');
131+
expect(editorStylesheet.href).not.to.contain('/epiceditor');
132+
});
133+
it('should NOT add the basePath path if the theme DOES have an absolute https link', function () {
134+
opts.theme.base = 'https://foo.com';
135+
editor = new EpicEditor(opts).load();
136+
editorStylesheet = getIframeDoc(editor.getElement('wrapperIframe')).getElementById('theme');
137+
expect(editorStylesheet.href).not.to.contain('/epiceditor');
138+
});
139+
});
140+
describe('.editor', function () {
141+
it('should add the basePath path if the theme does not have an absolute link', function () {
142+
opts.theme.editor = '/bar/';
143+
editor = new EpicEditor(opts).load();
144+
editorStylesheet = editor.getElement('editor').getElementById('theme');
145+
expect(editorStylesheet.href).to.contain('/epiceditor');
146+
});
147+
it('should NOT add the basePath path if the theme DOES have an absolute http link', function () {
148+
opts.theme.editor = 'http://bar.com';
149+
editor = new EpicEditor(opts).load();
150+
editorStylesheet = editor.getElement('editor').getElementById('theme');
151+
expect(editorStylesheet.href).not.to.contain('/epiceditor');
152+
});
153+
it('should NOT add the basePath path if the theme DOES have an absolute https link', function () {
154+
opts.theme.editor = 'https://bar.com';
155+
editor = new EpicEditor(opts).load();
156+
editorStylesheet = editor.getElement('editor').getElementById('theme');
157+
expect(editorStylesheet.href).not.to.contain('/epiceditor');
158+
});
159+
});
160+
describe('.preview', function () {
161+
it('should add the basePath path if the theme does not have an absolute link', function () {
162+
opts.theme.preview = '/baz/';
163+
editor = new EpicEditor(opts).load();
164+
editorStylesheet = editor.getElement('previewer').getElementById('theme');
165+
expect(editorStylesheet.href).to.contain('/epiceditor');
166+
});
167+
it('should NOT add the basePath path if the theme DOES have an absolute http link', function () {
168+
opts.theme.preview = 'http://baz.com';
169+
editor = new EpicEditor(opts).load();
170+
editorStylesheet = editor.getElement('previewer').getElementById('theme');
171+
expect(editorStylesheet.href).not.to.contain('/epiceditor');
172+
});
173+
it('should NOT add the basePath path if the theme DOES have an absolute https link', function () {
174+
opts.theme.preview = 'https://baz.com';
175+
editor = new EpicEditor(opts).load();
176+
editorStylesheet = editor.getElement('previewer').getElementById('theme');
177+
expect(editorStylesheet.href).not.to.contain('/epiceditor');
178+
});
179+
});
180+
});
115181
});

0 commit comments

Comments
 (0)