How can I test an event emitter inside an afterClosed mat dialog subscription?

I am trying to test an event emitter inside an afterClosed mat-dialog subscription and I’m really confused about how to do so.

My dialog function:

public openDialog(type: string): void {
  const newDialog = this.dialog.open(NewModalComponent, {
    width: '580px',
    data: {
      type: type,
      data: this.oldData
    }
  })

  newDialog.afterClosed().subscribe(result => {
    if(result) {
      this.updateState.emit({
        newData: result,
        oldData: this.oldData,
        type: type
      })
    }
  })
}

And here is my test:

// I'm not sure what to do or how to test if data will be emitted
it('should have data if apply was clicked', () => {
  spyOn(component.dialog, 'open').and.returnValue({afterClosed: () => of(true)})
  // something happens here?
})

Here is my mockDialog setup:

class MatDialogMock {
  open() {
    return {
      afterClosed: () => of({ data: 'returned data' })
    }
  }
}

describe('ButtonsComponent', () => {
  let component: ButtonsComponent
  let fixture: ComponentFixture<ButtonsComponent>
  let dialog: MatDialogMock

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        MaterialModule,
        NoopAnimationsModule
      ],
      declarations: [ 
        ButtonsComponent,
      ],
      providers: [
        {
          provide: MatDialog, useClass: MatDialogMock
        }
      ]
    })
    .compileComponents()
  }))

Has anyone been successful testing the results from the afterClosed subscription?

My tries:
This test fails with: : Expected a spy, but got Function.

it('should have data if apply was clicked', () => {
  spyOn(component.dialog, 'open').and.returnValue({afterClosed: () => of(true)})
  component.openDialog('Pending')
  expect(component.updateState.emit).toHaveBeenCalled()
})

This test fails with: test fails with Expected spy emit to have been called.

it('should have data if apply was clicked', () => {
  spyOn(component.dialog, 'open').and.returnValue({afterClosed: () => of(true)})
  component.openDialog('Pending')
  spyOn(component.updateState, 'emit')
  expect(component.updateState.emit).toHaveBeenCalled()
})

Source: New feed
Source Url How can I test an event emitter inside an afterClosed mat dialog subscription?