<commit_before>/*import { AuthenticationControllerMixin } from 'ember-simple-auth/mixins/authentication_controller_mixin';

var AuthenticatorMock = Ember.Object.extend();

var testController;
var TestController = Ember.Controller.extend(AuthenticationControllerMixin, {
  authenticator: 'authenticators:test',
  actions: {
    sessionAuthenticationSucceeded: function() {
      this.invokedSessionAuthenticationSucceeded = true;
    },
    sessionAuthenticationFailed: function(error) {
      this.invokedSessionAuthenticationFailed     = true;
      this.invokedSessionAuthenticationFailedWith = error;
    }
  }
});

var sessionMock;
var SessionMock = Ember.Object.extend({
  authenticate: function(authenticator, options) {
    this.invokedAuthenticate     = true;
    this.invokedAuthenticateWith = { authenticator: authenticator, options: options };
    return new Ember.RSVP.Promise(function(resolve, reject) {
      if (!!SessionMock._resolve) {
        resolve(SessionMock._resolve);
      } else {
        reject(SessionMock._reject);
      }
    });
  }
});

module('AuthenticationControllerMixin', {
  setup: function() {
    testController = TestController.create();
    sessionMock    = SessionMock.create();
    testController.set('session', sessionMock);
  }
});

test('authenticates the session', function() {
  Ember.run(function() {
    testController.send('authenticate', { 'key': 'value' });
  });

  ok(sessionMock.invokedAuthenticate, 'AuthenticationControllerMixin authenticates the session when authentication is triggered.');
  equal(sessionMock.invokedAuthenticateWith.authenticator, 'authenticators:test', 'AuthenticationControllerMixin authenticates the session with the correct authenticator.');
  deepEqual(sessionMock.invokedAuthenticateWith.options, { 'key': 'value' }, 'AuthenticationControllerMixin authenticates the session with the correct options.');
});

*/<commit_msg>converted tests for AuthenticationControllerMixin<commit_after>import { AuthenticationControllerMixin } from 'ember-simple-auth/mixins/authentication_controller_mixin';
import { Session } from 'ember-simple-auth/session';
import { Ephemeral as EphemeralStore } from 'ember-simple-auth/stores/ephemeral';

describe('AuthenticationControllerMixin', function() {
  describe('the "authenticate" action', function() {
    beforeEach(function() {
      this.session    = Session.create({ store: EphemeralStore.create() });
      this.controller = Ember.Controller.extend(AuthenticationControllerMixin, {
        authenticator: 'authenticatorFactory'
      }).create({ session: this.session });
    });

    it('authenticates the route', function() {
      sinon.spy(this.session, 'authenticate');
      this.controller._actions.authenticate.apply(this.controller, [{ some: 'options' }]);

      expect(this.session.authenticate.withArgs('authenticatorFactory', { some: 'options' }).calledOnce).to.be(true);
    });
  });
});

{'fraction_non_alphanumeric': 0.12235133287764867, 'fraction_numerical': 0.0, 'mean_word_length': 4.985685071574642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5041748', 'n_tokens_mistral': 805, 'n_tokens_neox': 783, 'n_words': 144}