it('should display message if dirty editor', () => {
      currentObject = new InstanceObject(CURRENT_OBJECT_TEMP_ID, IdocMocks.generateModels(), IdocMocks.generateIntialContent());
      currentObject.setDirty(true);
      let idocPage = IdocMocks.instantiateIdocPage();
      idocPage.currentObject = currentObject;

      handler.execute({}, {
        currentObject: currentObject,
        idocPageController: idocPage,
        idocContext: {
          reloadObjectDetails: () => PromiseStub.resolve()
        }
      });
      expect(dialogServiceStub.confirmation.callCount).to.equal(1);
    });
 it('should construct proper configuration object for actions loading', () => {
   let models = {
     path: [
       {id: 'emf:123456', type: 'projectinstance', compactHeader: 'compactHeader'},
       {id: 'emf:234567', type: 'documentinstance', compactHeader: 'compactHeader'}
     ]
   };
   let instanceObject = new InstanceObject('emf:123456', models, 'content');
   instanceObject.setContextPath(models.path);
   let config = ActionsHelper.getActionsLoaderConfig(instanceObject, 'placeholder');
   expect(config).to.deep.equal({
     'context-id': null,
     placeholder: 'placeholder',
     path: ['emf:123456', 'emf:234567']
   });
 });
  it('should stop draft interval and delete draft if object is persisted', () => {
    let deleteDraftSpy = sinon.spy(handler.idocDraftService, 'deleteDraft');

    currentObject = new InstanceObject(IDOC_ID, IdocMocks.generateModels(), IdocMocks.generateIntialContent());
    let idocPageController = {
      stopDraftInterval: sinon.stub(),
      appendContent: sinon.stub(),
      setViewMode: sinon.stub(),
      currentObject
    };

    let idocContext = {
      revertAllChanges: sinon.stub(),
      getAllSharedObjects: () => [],
      reloadObjectDetails: () => PromiseStub.resolve(),
      getCurrentObjectId: () => {
        return currentObject.getId();
      }
    };

    handler.execute({}, {
      currentObject: currentObject,
      idocPageController: idocPageController,
      idocContext: idocContext
    });

    let dialogConfig = handler.dialogService.confirmation.getCall(0).args[2];
    let dismissSpy = sinon.spy();
    dialogConfig.onButtonClick(DialogService.CONFIRM, undefined, {dismiss: dismissSpy});

    expect(idocPageController.stopDraftInterval.callCount).to.equal(1);
    expect(deleteDraftSpy.callCount).to.equal(1);
    expect(deleteDraftSpy.getCall(0).args[0]).to.equal(idocContext);
    expect(handler.validationService.init.callCount).to.equal(1);
  });
  it('should revert changes when editing iDoc', () => {
    currentObject = new InstanceObject(IDOC_ID, IdocMocks.generateModels(), IdocMocks.generateIntialContent());
    let idocPage = IdocMocks.instantiateIdocPage(IDOC_ID);
    idocPage.currentObject = currentObject;
    idocPage.currentObject.models.validationModel.field1.value = 'modified value';
    idocPage.tabsConfig.tabs[0].content = 'modified content';

    let sharedObjects = {};
    sharedObjects[IDOC_ID] = currentObject;

    currentObject.setDirty(true);

    let idocContext = new IdocContext();
    idocContext.sharedObjects = sharedObjects;
    idocContext.sharedObjectsRegistry.registerWidget('widget:123456', IDOC_ID);
    let revertAllChangesSpy = sinon.spy(idocContext, 'revertAllChanges');

    let validatorSpy = sinon.spy(handler.validationService, 'validate');

    _.extend(idocContext, {
      reloadObjectDetails: () => PromiseStub.resolve()
    });

    handler.execute({}, {
      currentObject: currentObject,
      idocPageController: idocPage,
      idocContext: idocContext
    });

    let dialogConfig = handler.dialogService.confirmation.getCall(0).args[2];
    let dismissSpy = sinon.spy();
    dialogConfig.onButtonClick(DialogService.CONFIRM, undefined, {dismiss: dismissSpy});

    expect(validatorSpy.called).to.be.true;
    expect(idocPage.currentObject.models.validationModel.field1).to.have.property('value', 'value1');
    expect(idocPage.tabsConfig.tabs[0]).to.have.property('content', 'Content 0');
    expect(revertAllChangesSpy.callCount).to.equal(1);
    expect(handler.validationService.init.callCount).to.equal(1);
  });
 getCurrentObjectId: () => {
   return currentObject.getId();
 }