@@ -969,13 +969,30 @@ describe('addBlockedChore', () => {
969
969
const blockedChore1 = createMockChore ( ChoreType . VISIBLE , { el : 'host1' } ) ;
970
970
const blockedChore2 = createMockChore ( ChoreType . TASK , { el : 'host2' } ) ;
971
971
const blockingChore = createMockChore ( ChoreType . NODE_DIFF , { el : 'host3' } ) ;
972
- blockingChore . $blockedChores$ = [ blockedChore1 ] ;
972
+ blockingChore . $blockedChores$ = new ChoreArray ( ) ;
973
+ blockingChore . $blockedChores$ . add ( blockedChore1 ) ;
973
974
const blockedChores = new Set < Chore > ( [ blockedChore1 ] ) ;
974
975
975
976
addBlockedChore ( blockedChore2 , blockingChore , blockedChores ) ;
976
977
977
- expect ( blockingChore . $blockedChores$ ) . toEqual ( [ blockedChore1 , blockedChore2 ] ) ;
978
+ expect ( blockingChore . $blockedChores$ ) . toEqual ( [ blockedChore2 , blockedChore1 ] ) ;
978
979
expect ( blockedChores . has ( blockedChore1 ) ) . toBe ( true ) ;
979
980
expect ( blockedChores . has ( blockedChore2 ) ) . toBe ( true ) ;
980
981
} ) ;
982
+
983
+ it ( 'should not add duplicate blocked chores' , ( ) => {
984
+ const blockedChore = createMockChore ( ChoreType . VISIBLE , { el : 'host1' } ) ;
985
+ const blockingChore = createMockChore ( ChoreType . NODE_DIFF , { el : 'host2' } ) ;
986
+ const blockedChores = new Set < Chore > ( ) ;
987
+
988
+ // Add the same blocked chore twice
989
+ addBlockedChore ( blockedChore , blockingChore , blockedChores ) ;
990
+ addBlockedChore ( blockedChore , blockingChore , blockedChores ) ;
991
+
992
+ // Should only contain the chore once
993
+ expect ( blockingChore . $blockedChores$ ) . toEqual ( [ blockedChore ] ) ;
994
+ expect ( blockingChore . $blockedChores$ ?. length ) . toBe ( 1 ) ;
995
+ expect ( blockedChores . has ( blockedChore ) ) . toBe ( true ) ;
996
+ expect ( blockedChores . size ) . toBe ( 1 ) ;
997
+ } ) ;
981
998
} ) ;
0 commit comments