@@ -25,6 +25,61 @@ describe("indexCheck", () => {
2525 expect ( usesIndex ( explainResult ) ) . toBe ( true ) ;
2626 } ) ;
2727
28+ it ( "should return true for IDHACK" , ( ) => {
29+ const explainResult : Document = {
30+ queryPlanner : {
31+ winningPlan : {
32+ stage : "IDHACK" ,
33+ } ,
34+ } ,
35+ } ;
36+ expect ( usesIndex ( explainResult ) ) . toBe ( true ) ;
37+ } ) ;
38+
39+ it ( "should return true for EXPRESS_IXSCAN (MongoDB 8.0+)" , ( ) => {
40+ const explainResult : Document = {
41+ queryPlanner : {
42+ winningPlan : {
43+ stage : "EXPRESS_IXSCAN" ,
44+ } ,
45+ } ,
46+ } ;
47+ expect ( usesIndex ( explainResult ) ) . toBe ( true ) ;
48+ } ) ;
49+
50+ it ( "should return true for EXPRESS_CLUSTERED_IXSCAN (MongoDB 8.0+)" , ( ) => {
51+ const explainResult : Document = {
52+ queryPlanner : {
53+ winningPlan : {
54+ stage : "EXPRESS_CLUSTERED_IXSCAN" ,
55+ } ,
56+ } ,
57+ } ;
58+ expect ( usesIndex ( explainResult ) ) . toBe ( true ) ;
59+ } ) ;
60+
61+ it ( "should return true for EXPRESS_UPDATE (MongoDB 8.0+)" , ( ) => {
62+ const explainResult : Document = {
63+ queryPlanner : {
64+ winningPlan : {
65+ stage : "EXPRESS_UPDATE" ,
66+ } ,
67+ } ,
68+ } ;
69+ expect ( usesIndex ( explainResult ) ) . toBe ( true ) ;
70+ } ) ;
71+
72+ it ( "should return true for EXPRESS_DELETE (MongoDB 8.0+)" , ( ) => {
73+ const explainResult : Document = {
74+ queryPlanner : {
75+ winningPlan : {
76+ stage : "EXPRESS_DELETE" ,
77+ } ,
78+ } ,
79+ } ;
80+ expect ( usesIndex ( explainResult ) ) . toBe ( true ) ;
81+ } ) ;
82+
2883 it ( "should return false for COLLSCAN" , ( ) => {
2984 const explainResult : Document = {
3085 queryPlanner : {
@@ -50,6 +105,20 @@ describe("indexCheck", () => {
50105 expect ( usesIndex ( explainResult ) ) . toBe ( true ) ;
51106 } ) ;
52107
108+ it ( "should return true for nested EXPRESS_IXSCAN in inputStage" , ( ) => {
109+ const explainResult : Document = {
110+ queryPlanner : {
111+ winningPlan : {
112+ stage : "SORT" ,
113+ inputStage : {
114+ stage : "EXPRESS_IXSCAN" ,
115+ } ,
116+ } ,
117+ } ,
118+ } ;
119+ expect ( usesIndex ( explainResult ) ) . toBe ( true ) ;
120+ } ) ;
121+
53122 it ( "should return false for unknown stage types" , ( ) => {
54123 const explainResult : Document = {
55124 queryPlanner : {
0 commit comments