{
  "description": "replicaset-emit-topology-description-changed-before-close",
  "schemaVersion": "1.20",
  "runOnRequirements": [
    {
      "topologies": [
        "replicaset"
      ],
      "minServerVersion": "4.4"
    }
  ],
  "tests": [
    {
      "description": "Topology lifecycle",
      "operations": [
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "client": {
                  "id": "client",
                  "observeEvents": [
                    "topologyDescriptionChangedEvent",
                    "topologyOpeningEvent",
                    "topologyClosedEvent"
                  ]
                }
              }
            ]
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "topologyDescriptionChangedEvent": {}
            },
            "count": 4
          }
        },
        {
          "name": "close",
          "object": "client"
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "eventType": "sdam",
          "ignoreExtraEvents": false,
          "events": [
            {
              "topologyOpeningEvent": {}
            },
            {
              "topologyDescriptionChangedEvent": {}
            },
            {
              "topologyDescriptionChangedEvent": {}
            },
            {
              "topologyDescriptionChangedEvent": {}
            },
            {
              "topologyDescriptionChangedEvent": {}
            },
            {
              "topologyDescriptionChangedEvent": {
                "previousDescription": {
                  "type": "ReplicaSetWithPrimary"
                },
                "newDescription": {
                  "type": "Unknown"
                }
              }
            },
            {
              "topologyClosedEvent": {}
            }
          ]
        }
      ]
    }
  ]
}
