35 lines
989 B
CoffeeScript
35 lines
989 B
CoffeeScript
{Tasklist, Task} = require '../src/task'
|
|
|
|
describe 'Task instance', ->
|
|
task1 = task2 = null
|
|
it 'has name', ->
|
|
task1 = new Task 'feed the cat'
|
|
task1.name.should.equal 'feed the cat'
|
|
|
|
it 'is initially incomplete', ->
|
|
task1.status.should.equal 'incomplete'
|
|
|
|
it 'is able to be completed', ->
|
|
task1.complete().should.be.true
|
|
task1.status.should.equal 'complete'
|
|
|
|
it 'is able to to be dependent on another task', ->
|
|
task1 = new Task 'wash dishes'
|
|
task2 = new Task 'dry dishes'
|
|
|
|
task2.dependsOn task1
|
|
|
|
task2.status.should.equal 'dependent'
|
|
task2.parent.should.equal task1
|
|
task1.child.should.equal task2
|
|
|
|
it 'refuses completed if it is dependent on an uncompleted task', ->
|
|
task1 = new Task 'wash dishes'
|
|
task2 = new Task 'dry dishes'
|
|
|
|
task2.dependsOn task1
|
|
|
|
task2.status.should.equal 'dependent'
|
|
task2.parent.should.equal task1
|
|
task1.child.should.equal task2
|
|
-> task2.complete().should.throw "Dependent task 'wash dishes' is not completed." |