summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/services/recover_service.spec.js
blob: 86fe9f87876ecb3120c8edef34cdc4a8cdc80c23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
describeComponent('services/recover_service', function () {
  'use strict';

  var i18n;

  beforeEach( function () {
    this.setupComponent();
    i18n = require('views/i18n');
  });

  var mail1 = {
    ident: 42,
    isInTrash: function() { return false; }
  };

  var mail2 = {
    ident: 34,
    isInTrash: function() { return true; }
  };

  it('moves selected emails from trash back to inbox', function () {
    var mailRecoverManyEvent = spyOnEvent(document, Pixelated.events.mail.recoverMany);
    this.component.trigger(document, Pixelated.events.ui.mail.recoverMany, {checkedMails: {mail1: mail1, mail2: mail2}});

    var expectedRecoverManyEventData = {
      mails: [mail1, mail2],
      successMessage: i18n('Your messages were moved to inbox!')
    };

    expect(mailRecoverManyEvent).toHaveBeenTriggeredOnAndWith(document, expectedRecoverManyEventData);
  });
});