mirror of
https://github.com/wickedest/Mergely.git
synced 2026-02-02 09:38:00 +08:00
This commit is contained in:
@@ -449,7 +449,6 @@ CodeMirrorDiffView.prototype.bind = function(container) {
|
||||
ev.preventDefault();
|
||||
return;
|
||||
}
|
||||
const ed = this.editor[side];
|
||||
// See if the user clicked the line number of a difference:
|
||||
let found = false;
|
||||
for (let i = 0; i < this.changes.length; ++i) {
|
||||
|
||||
@@ -122,13 +122,11 @@ class Mergely {
|
||||
const colors = dom.getColors(this.el);
|
||||
this._options = {
|
||||
...defaultOptions,//lgpl
|
||||
...this._initOptions,
|
||||
...(this._options || this._initOptions),
|
||||
...options//lgpl-separate-notice
|
||||
};
|
||||
this._viewOptions = {
|
||||
...defaultOptions,
|
||||
...this._initOptions,
|
||||
...options,
|
||||
...this._options,
|
||||
_colors: colors
|
||||
};
|
||||
}
|
||||
|
||||
@@ -340,7 +340,6 @@ describe('markup', () => {
|
||||
name: 'Changes with non-letter chars',
|
||||
lhs: '~# 00 == ! (dog) \n',
|
||||
rhs: '~? 11 ++ ] (fox) .\n',
|
||||
only: true,
|
||||
check: (editor) => {
|
||||
expect(editor.querySelectorAll(LHS_CHANGE_START_AND_END + '.cid-0')).to.have.length(1);
|
||||
expect(editor.querySelectorAll(LHS_INLINE_TEXT + '.cid-0')).to.have.length(6);
|
||||
@@ -355,8 +354,6 @@ describe('markup', () => {
|
||||
for (const value of rhs_changes.values()) {
|
||||
rhs_values.push(value.innerText);
|
||||
}
|
||||
console.log(lhs_values);
|
||||
console.log(rhs_values);
|
||||
expect(lhs_values).to.deep.equal(['#', '00', '==', '!', 'd', 'g']);
|
||||
expect(rhs_values).to.deep.equal(['?', '11', '++', ']', 'f', 'x', '.']);
|
||||
}
|
||||
|
||||
@@ -62,19 +62,17 @@ describe('mergely', function () {
|
||||
try {
|
||||
const { children } = editor.el.children[0];
|
||||
const items = Array.from(children).map(a => a.className);
|
||||
expect(items[0] == 'mergely-margin');
|
||||
expect(items[1] == 'mergely-column');
|
||||
// NOTE: if running karma debug, these tests can fail because
|
||||
// the debugger grabs the focus and the CodeMirror instance
|
||||
// loses `CodeMirror-focused`
|
||||
expect(items).to.deep.equal([
|
||||
'mergely-margin',
|
||||
'mergely-column',
|
||||
'CodeMirror cm-s-default CodeMirror-focused',
|
||||
'mergely-canvas',
|
||||
'mergely-column',
|
||||
'CodeMirror cm-s-default',
|
||||
'mergely-margin',
|
||||
'mergely-splash'
|
||||
]);
|
||||
expect(items[2].indexOf('CodeMirror cm-s-default' == 0));
|
||||
expect(items[3] == 'mergely-margin');
|
||||
expect(items[4] == 'mergely-column');
|
||||
expect(items[5] == 'CodeMirror cm-s-default');
|
||||
expect(items[6] == 'mergely-column');
|
||||
expect(items[7] == 'mergely-splash');
|
||||
expect(editor.get('lhs')).to.equal('');
|
||||
expect(editor.get('rhs')).to.equal('');
|
||||
done();
|
||||
@@ -99,15 +97,17 @@ describe('mergely', function () {
|
||||
// NOTE: if running karma debug, these tests can fail because
|
||||
// the debugger grabs the focus and the CodeMirror instance
|
||||
// loses `CodeMirror-focused`
|
||||
expect(items).to.deep.equal([
|
||||
'mergely-margin',
|
||||
'mergely-column',
|
||||
'CodeMirror cm-s-default CodeMirror-focused',
|
||||
'mergely-canvas',
|
||||
'mergely-column',
|
||||
'CodeMirror cm-s-default',
|
||||
'mergely-margin'
|
||||
]);
|
||||
expect(items[0] == 'mergely-margin');
|
||||
expect(items[1] == 'mergely-column');
|
||||
// NOTE: if running karma debug, these tests can fail because
|
||||
// the debugger grabs the focus and the CodeMirror instance
|
||||
// loses `CodeMirror-focused`
|
||||
expect(items[2].indexOf('CodeMirror cm-s-default' == 0));
|
||||
expect(items[3] == 'mergely-margin');
|
||||
expect(items[4] == 'mergely-column');
|
||||
expect(items[5] == 'CodeMirror cm-s-default');
|
||||
expect(items[6] == 'mergely-column');
|
||||
expect(items[7] == 'mergely-splash');
|
||||
expect(editor.get('lhs')).to.equal('left-hand side text');
|
||||
expect(editor.get('rhs')).to.equal('right-hand side text');
|
||||
done();
|
||||
@@ -129,18 +129,17 @@ describe('mergely', function () {
|
||||
try {
|
||||
const { children } = editor.el.children[0];
|
||||
const items = Array.from(children).map(a => a.className);
|
||||
expect(items[0] == 'mergely-margin');
|
||||
expect(items[1] == 'mergely-column');
|
||||
// NOTE: if running karma debug, these tests can fail because
|
||||
// the debugger grabs the focus and the CodeMirror instance
|
||||
// loses `CodeMirror-focused`
|
||||
expect(items).to.deep.equal([
|
||||
'mergely-margin',
|
||||
'mergely-column',
|
||||
'CodeMirror cm-s-default CodeMirror-focused',
|
||||
'mergely-canvas',
|
||||
'mergely-column',
|
||||
'CodeMirror cm-s-default',
|
||||
'mergely-margin'
|
||||
]);
|
||||
expect(items[2].indexOf('CodeMirror cm-s-default' == 0));
|
||||
expect(items[3] == 'mergely-margin');
|
||||
expect(items[4] == 'mergely-column');
|
||||
expect(items[5] == 'CodeMirror cm-s-default');
|
||||
expect(items[6] == 'mergely-column');
|
||||
expect(items[7] == 'mergely-splash');
|
||||
expect(editor.get('lhs')).to.equal('left-hand side text');
|
||||
expect(editor.get('rhs')).to.equal('right-hand side text');
|
||||
done();
|
||||
@@ -161,18 +160,17 @@ describe('mergely', function () {
|
||||
try {
|
||||
const { children } = editor.el.children[0];
|
||||
const items = Array.from(children).map(a => a.className);
|
||||
expect(items[0] == 'mergely-margin');
|
||||
expect(items[1] == 'mergely-column');
|
||||
// NOTE: if running karma debug, these tests can fail because
|
||||
// the debugger grabs the focus and the CodeMirror instance
|
||||
// loses `CodeMirror-focused`
|
||||
expect(items).to.deep.equal([
|
||||
'mergely-margin',
|
||||
'mergely-column',
|
||||
'CodeMirror cm-s-default CodeMirror-focused',
|
||||
'mergely-canvas',
|
||||
'mergely-column',
|
||||
'CodeMirror cm-s-default',
|
||||
'mergely-margin'
|
||||
]);
|
||||
expect(items[2].indexOf('CodeMirror cm-s-default' == 0));
|
||||
expect(items[3] == 'mergely-margin');
|
||||
expect(items[4] == 'mergely-column');
|
||||
expect(items[5] == 'CodeMirror cm-s-default');
|
||||
expect(items[6] == 'mergely-column');
|
||||
expect(items[7] == 'mergely-splash');
|
||||
expect(children[0].style.visibility).to.equal('hidden');
|
||||
expect(children[6].style.visibility).to.equal('hidden');
|
||||
done();
|
||||
@@ -503,6 +501,24 @@ describe('mergely', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should preserve changed option', function (done) {
|
||||
const editor = init({
|
||||
change_timeout: 0,
|
||||
license: 'lgpl-separate-notice',
|
||||
lhs: 'left-hand side text',
|
||||
rhs: 'right-hand side text'
|
||||
});
|
||||
editor.once('updated', () => {
|
||||
editor.options({ sidebar: false });
|
||||
expect(editor.options().wrap_lines).to.equal(false, 'wrap_lines');
|
||||
expect(editor.options().sidebar).to.equal(false, 'sidebar');
|
||||
editor.options({ wrap_lines: false });
|
||||
expect(editor.options().wrap_lines).to.equal(false, 'wrap_lines-2');
|
||||
expect(editor.options().sidebar).to.equal(false, 'sidebar-2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should ignore white-space', function (done) {
|
||||
const editor = init({
|
||||
height: 100,
|
||||
|
||||
Reference in New Issue
Block a user