describe("the scheduler", function() {
    
    var event1 = {summary: "one", dtstart: "2011-01-30T17:00"};
    var event2 = {summary: "two", dtstart: "2011-01-30T20:00"};
    
    
    it("should order events by time", function() {
        var schedule = Lange.schedule([event2, event1]);
        expect(schedule).toEqual([
            {dtstart: event1.dtstart, event: event1}, 
            {dtstart: event2.dtstart, event: event2}, 
            ]);
    });
    
    it("should handle events with no time", function() {
        var eventWithNoDate = {summary: "foo"};
        var schedule = Lange.schedule([event1, eventWithNoDate]);
        expect(schedule).toEqual([
            {dtstart: event1.dtstart, event: event1}, 
            {dtstart: eventWithNoDate.dtstart, event: eventWithNoDate},
            ]);
    });
    
    it("should recognise conflicts and return them in the result", function(){
        var eventWhichConflictsWithEvent2 = {summary: "three", dtstart: "2011-01-30T20:00"};
        var schedule = Lange.schedule([event1, event2, eventWhichConflictsWithEvent2]);
        expect(schedule).toEqual([
            {dtstart: event1.dtstart, event: event1}, 
            {dtstart: event2.dtstart, conflict: true, events: [event2, eventWhichConflictsWithEvent2]}
            ]);
        
    });
    
    it("should throw exception if not given an array of events", function(){
        
    });
    
});        
@@ -1,52 +1,64 @@
-describe(%22the scheduler%22, function() %7B%0A    %0A    
+var event1 = %7Bsummary: %22one%22, dtstart: %222011-01-30T17:00%22%7D;%0A
 var 
@@ -54,33 +54,33 @@
 :00%22%7D;%0Avar event
-1
+2
  = %7Bsummary: %22on
@@ -69,35 +69,35 @@
 t2 = %7Bsummary: %22
-one
+two
 %22, dtstart: %22201
@@ -108,21 +108,17 @@
 -30T
-17
+20
 :00%22%7D;%0A
-    
 var 
@@ -114,32 +114,55 @@
 :00%22%7D;%0Avar event
+WhichConflictsWithEvent
 2 = %7Bsummary: %22t
@@ -153,34 +153,36 @@
 2 = %7Bsummary: %22t
-wo
+hree
 %22, dtstart: %22201
@@ -202,149 +202,705 @@
 %22%7D;%0A
-    %0A    %0A    it(%22should order events by time%22, function() %7B%0A        var schedule = Lange.schedule(%5Bevent2, event1%5D);%0A        expect(schedule
+%0Afunction conflict(events)%7B%0A    return %7Bconflict: true, events: events%7D%0A%7D;%0A%0Afunction scheduleWith(eventSpecs)%7B%0A    return eventSpecs.map(function(eventSpec)%7B%0A        var slot = %7B%7D;%0A        if (eventSpec.conflict)%7B%0A           slot.conflict = true;%0A           slot.dtstart = eventSpec.events%5B0%5D.dtstart;%0A           slot.events = eventSpec.events; %0A        %7D%0A        else %7B%0A         slot.dtstart = eventSpec.dtstart;    %0A         slot.event = eventSpec;%0A        %7D;%0A        return slot;%0A    %7D);%0A%7D%0A%0Adescribe(%22test helper code%22, function()%7B%0A    it(%22should generate the correct expected representation%22, function()%7B%0A        expect(scheduleWith(%5Bevent1, conflict(%5Bevent2, eventWhichConflictsWithEvent2%5D)%5D)
 ).to
@@ -952,33 +952,32 @@
  event: event1%7D,
- 
 %0A            %7Bdt
@@ -1002,39 +1002,318 @@
 art,
+ conflict: true,
  event
+s
 : 
+%5B
 event2
-%7D, %0A            %5D
+, eventWhichConflictsWithEvent2%5D%7D,%0A            %5D);%0A    %7D);%0A%7D);%0A%0Adescribe(%22the scheduler%22, function() %7B    %0A    it(%22should order events by time%22, function() %7B%0A        var schedule = Lange.schedule(%5Bevent2, event1%5D);%0A        expect(schedule).toEqual(scheduleWith(%5Bevent1, event2%5D)
 );%0A 
@@ -1532,118 +1532,29 @@
 ual(
-%5B%0A            %7Bdtstart: event1.dtstart, event: event1%7D, %0A            %7Bdtstart: eventWithNoDate.dtstart, 
+scheduleWith(%5B
 event
-:
+1,
  eve
@@ -1565,32 +1565,18 @@
 thNoDate
-%7D,%0A            
 %5D
+)
 );%0A    %7D
@@ -1666,101 +1666,8 @@
 ()%7B%0A
-        var eventWhichConflictsWithEvent2 = %7Bsummary: %22three%22, dtstart: %222011-01-30T20:00%22%7D;%0A
     
@@ -1787,127 +1787,39 @@
 ual(
-%5B%0A            %7Bdtstart: event1.dtstart, event: event1%7D, %0A            %7Bdtstart: event2.dtstart, conflict: true, events: 
+scheduleWith(%5Bevent1, conflict(
 %5Beve
@@ -1857,34 +1857,13 @@
 nt2%5D
-%7D%0A            %5D);%0A        
+)%5D));
 %0A   

refactor test code