Improving cancel task edit functionality. closes #7688

This commit is contained in:
Husman
2016-06-18 17:45:30 -07:00
parent 813aa2cf38
commit f35c4df022
6 changed files with 101 additions and 75 deletions

View File

@@ -30,11 +30,89 @@ describe('Tasks Controller', function() {
});
describe('editTask', function() {
it('is Tasks.editTask', function() {
inject(function(Tasks) {
expect(scope.editTask).to.eql(Tasks.editTask);
});
var task;
beforeEach(function(){
task = specHelper.newTask();
});
it('toggles the _editing property', function() {
scope.editTask(task, user);
expect(task._editing).to.eql(true);
});
it('sets _tags to true by default', function() {
scope.editTask(task, user);
expect(task._tags).to.eql(true);
});
it('sets _tags to false if preference for collapsed tags is turned on', function() {
user.preferences.tagsCollapsed = true;
scope.editTask(task, user);
expect(task._tags).to.eql(false);
});
it('sets _advanced to true by default', function(){
user.preferences.advancedCollapsed = true;
scope.editTask(task, user);
expect(task._advanced).to.eql(false);
});
it('sets _advanced to false if preference for collapsed advance menu is turned on', function() {
user.preferences.advancedCollapsed = false;
scope.editTask(task, user);
expect(task._advanced).to.eql(true);
});
});
describe('cancelEdit', function() {
var task;
beforeEach(function(){
task = specHelper.newTask();
});
it('resets the task text', function() {
let originalText = task.text;
scope.editTask(task, user);
task.text = 'test';
scope.cancelTaskEdit(task)
expect(task.text).to.be.eql(originalText);
});
it('resets the task notes', function() {
let originalNotes = task.notes;
scope.editTask(task, user);
task.notes = 'test';
scope.cancelTaskEdit(task)
expect(task.notes).to.be.eql(originalNotes);
});
it('resets the task alias', function() {
task.alias = 'alias';
let originalAlias = task.alias;
scope.editTask(task, user);
task.alias = 'test';
scope.cancelTaskEdit(task)
expect(task.alias).to.be.eql(originalAlias);
});
it('resets the task priority', function() {
let originalPriority = task.priority;
scope.editTask(task, user);
task.priority = 'test';
scope.cancelTaskEdit(task)
expect(task.priority).to.be.eql(originalPriority);
});
});
describe('removeTask', function() {