From bb787df2e3040ffeffdf645442bf48f0ee715882 Mon Sep 17 00:00:00 2001 From: Jamie Peabody Date: Sun, 30 Jan 2022 12:00:48 +0000 Subject: [PATCH] chore: test initial options --- src/diff-view.js | 1 - test/mergely.spec.js | 69 +++++++++++++++++++------------------------- 2 files changed, 30 insertions(+), 40 deletions(-) diff --git a/src/diff-view.js b/src/diff-view.js index dcc590a..b9a9ee2 100644 --- a/src/diff-view.js +++ b/src/diff-view.js @@ -96,7 +96,6 @@ CodeMirrorDiffView.prototype.init = function(el, options = {}) { rhs_cmsettings: {}, lhs: function(setValue) { }, rhs: function(setValue) { }, - loaded: function() { }, _debug: false, // user supplied options ...options diff --git a/test/mergely.spec.js b/test/mergely.spec.js index 188077f..e64f3c9 100644 --- a/test/mergely.spec.js +++ b/test/mergely.spec.js @@ -14,13 +14,16 @@ const defaultOptions = { ignorecase: false, ignoreaccents: false, resize_timeout: 500, - change_timeout: 150, + change_timeout: 50, + lhs_cmsettings: {}, + rhs_cmsettings: {}, bgcolor: '#eee', vpcolor: 'rgba(0, 0, 200, 0.5)', - license: 'lgpl-separate-notice', + license: 'lgpl', cmsettings: { styleSelectedText: true - } + }, + _debug: false }; describe('mergely', function () { @@ -47,10 +50,7 @@ describe('mergely', function () { describe('initialization', () => { it('initializes without arguments', (done) => { - const editor = init({ - height: 100, - license: 'lgpl-separate-notice' - }); + const editor = init(); expect(editor).to.exist; editor.once('updated', () => { const { children } = editor.el; @@ -130,38 +130,6 @@ describe('mergely', function () { }); }); - it('initializes with default options', function (done) { - const editor = init(); - editor.once('updated', () => { - const options = editor.options(); - expect(options).to.deep.include({ - rhs_margin: 'right', - wrap_lines: false, - line_numbers: true, - lcs: true, - sidebar: true, - viewport: false, - ignorews: false, - ignorecase: false, - ignoreaccents: false, - resize_timeout: 500, - change_timeout: 50, - bgcolor: '#eee', - vpcolor: 'rgba(0, 0, 200, 0.5)', - license: 'lgpl', - cmsettings: { - styleSelectedText: true - }, - lhs_cmsettings: {}, - rhs_cmsettings: {} - }); - expect(options.lhs).to.be.a('function'); - expect(options.rhs).to.be.a('function'); - expect(options.loaded).to.be.a('function'); - done(); - }); - }); - it('initializes with options', function () { const initOptions = { fgcolor: { @@ -740,6 +708,29 @@ describe('mergely', function () { }); describe('options', () => { + it('should have default options', function (done) { + const editor = init(); + const test = () => { + try { + const currentOptions = editor.options(); + expect(currentOptions).to.deep.equal({ + ...defaultOptions, + lhs: currentOptions.lhs, + rhs: currentOptions.rhs + }); + done(); + } catch (ex) { + done(ex); + } + }; + editor.once('updated', () => { + currentOptions = editor.options(); + editor.once('updated', test); + editor.options({}); + test(); + }); + }); + it('should not change any options if object empty', function (done) { let currentOptions; const editor = init({