Mongoclient.spec.js, understanding why code was written like this?

I was looking through the code and noticed this block of code. I was just wondering why we are checking for undefined then also checking twice for the .ssl property?

Wouldn’t it be acceptable just to have expect().toHaveProperty(“ssl”) and be done with that test?

Really just asking out of curiosity as I’m still very new to jest and mongodb.

  // expect this connection to have SSL enabled
  if (typeof clientOptions.ssl !== "undefined") {  
    expect(clientOptions).toHaveProperty("ssl") // is the connection ssl?
    expect(clientOptions.ssl).toBe(true)  // 

    // expect this user to authenticate against the "admin" database

I think this code snippet is not checking twice for the ssl property. In the if statement, there’s an expression typeof clientOptions.ssl !== "undefined" to see if the object clientOptions has the property ssl. If the expression evaluated to false, then testing four assertions in the if block(including expect(clientOptions).toHaveProperty("ssl") would be a waste of time. So to clearly prevent this situation, if statement is used here.