@@ -51,14 +51,16 @@ describe('PriorityQueue', () => {
51
51
expect ( priorityQueue . poll ( ) ) . toBe ( 5 ) ;
52
52
} ) ;
53
53
54
- it ( 'should be possible to change priority of internal nodes ' , ( ) => {
54
+ it ( 'should be possible to change priority of head node ' , ( ) => {
55
55
const priorityQueue = new PriorityQueue ( ) ;
56
56
57
57
priorityQueue . add ( 10 , 1 ) ;
58
58
priorityQueue . add ( 5 , 2 ) ;
59
59
priorityQueue . add ( 100 , 0 ) ;
60
60
priorityQueue . add ( 200 , 0 ) ;
61
61
62
+ expect ( priorityQueue . peek ( ) ) . toBe ( 100 ) ;
63
+
62
64
priorityQueue . changePriority ( 100 , 10 ) ;
63
65
priorityQueue . changePriority ( 10 , 20 ) ;
64
66
@@ -68,14 +70,16 @@ describe('PriorityQueue', () => {
68
70
expect ( priorityQueue . poll ( ) ) . toBe ( 10 ) ;
69
71
} ) ;
70
72
71
- it ( 'should be possible to change priority of head node ' , ( ) => {
73
+ it ( 'should be possible to change priority of internal nodes ' , ( ) => {
72
74
const priorityQueue = new PriorityQueue ( ) ;
73
75
74
76
priorityQueue . add ( 10 , 1 ) ;
75
77
priorityQueue . add ( 5 , 2 ) ;
76
78
priorityQueue . add ( 100 , 0 ) ;
77
79
priorityQueue . add ( 200 , 0 ) ;
78
80
81
+ expect ( priorityQueue . peek ( ) ) . toBe ( 100 ) ;
82
+
79
83
priorityQueue . changePriority ( 200 , 10 ) ;
80
84
priorityQueue . changePriority ( 10 , 20 ) ;
81
85
0 commit comments