The Open Source kanban (built with Meteor). Keep variable/table/field names camelCase. For translations, only add Pull Request changes to wekan/i18n/en.i18n.json , other translations are done at https://transifex.com/wekan/wekan only.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
wekan/server/lib/tests/titleChangeActivity.tests.js

44 lines
1.7 KiB

/* eslint-env mocha */
import { expect } from 'chai';
import { titleChanged } from '../titleChangeActivity';
describe('titleChangeActivity', function() {
describe(titleChanged.name, function() {
it('returns true when the modifier changes title to a different value', function() {
const oldDoc = { title: 'Old title' };
const modifier = { $set: { title: 'New title' } };
expect(titleChanged(oldDoc, modifier)).to.equal(true);
});
it('returns false when title is absent from the modifier', function() {
const oldDoc = { title: 'Old title' };
const modifier = { $set: { description: 'changed' } };
expect(titleChanged(oldDoc, modifier)).to.equal(false);
});
it('returns false when the title is unchanged', function() {
const oldDoc = { title: 'Same title' };
const modifier = { $set: { title: 'Same title' } };
expect(titleChanged(oldDoc, modifier)).to.equal(false);
});
it('returns true when a title is set on a card that had none', function() {
const oldDoc = {};
const modifier = { $set: { title: 'First title' } };
expect(titleChanged(oldDoc, modifier)).to.equal(true);
});
it('returns false for falsy / malformed modifiers', function() {
expect(titleChanged({ title: 'x' }, undefined)).to.equal(false);
expect(titleChanged({ title: 'x' }, null)).to.equal(false);
expect(titleChanged({ title: 'x' }, {})).to.equal(false);
expect(titleChanged({ title: 'x' }, { $set: {} })).to.equal(false);
});
it('tolerates a missing oldDoc', function() {
const modifier = { $set: { title: 'New title' } };
expect(titleChanged(undefined, modifier)).to.equal(true);
expect(titleChanged(null, modifier)).to.equal(true);
});
});
});