Skip to content

Commit

Permalink
Implement 100% coverage for target models
Browse files Browse the repository at this point in the history
  • Loading branch information
tormozz48 committed Feb 13, 2015
1 parent a5c06e3 commit 8f95d07
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ var fs = require('fs'),
},
LOG_DIR = path.join(process.cwd(), 'logs');

fs.mkdirSync(LOG_DIR);
try {
fs.mkdirSync(LOG_DIR);
}catch (err) {
err;
}

intel.setLevel('debug');
intel.addHandler(
Expand Down
42 changes: 40 additions & 2 deletions test/targets/base.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
var should = require('should'),
var vow = require('vow'),
should = require('should'),
Target = require('../../src/targets/base'),
Changes = require('../../src/model/changes'),
target;
target,
task1,
task2;

describe('describe task base', function () {
before(function () {
target = new Target({});
task1 = function (t) {
t.getChanges().getDocs().addAdded(1);
t.result = 1;
return vow.resolve(t);
};
task2 = function (t) {
t.getChanges().getDocs().addAdded(1);
t.result = 2;
return vow.resolve(t);
};
});

it('should have valid name', function () {
Expand Down Expand Up @@ -42,4 +55,29 @@ describe('describe task base', function () {
it('should have snapshot name after it was set', function () {
target.getSnapshotName().should.equal('11:2:2015-16:28:54');
});

it('should add tasks', function () {
target.addTask(task1);
target.addTask(task2);
target.getTasks().should.be.ok;
target.getTasks().should.be.instanceOf(Array).and.have.length(2);
});

it('should execute tasks', function () {
target.execute().then(function (t) {
t.result.should.equal(2);
t.getChanges().getDocs().getAdded().should.be.instanceOf(Array).and.have.length(2);
})
});

it('should clear changes', function () {
var r = target.clearChanges();
r.should.be.instanceOf(Target);
r.getChanges().getDocs().getAdded().should.be.instanceOf(Array).and.have.length(0);
});

it('should init target with empty options if they were not given', function () {
var t = new Target();
t.getOptions().should.be.empty;
});
});

0 comments on commit 8f95d07

Please sign in to comment.