<commit_before>/* jshint expr:true */
import Ember from 'ember';
import { expect } from 'chai';
import { describe, beforeEach, it } from 'mocha';
import sinon from 'sinon';
import { MicroState } from 'ember-microstates';

describe.only('Microstates', function() {
  let onState = null;
  let onCustom = null;
  let onStateEvent = null;
  let onCustomEvent = null;
  let onRecompute = null;
  beforeEach(function() {
    [onState, onCustom, onStateEvent, onCustomEvent, onRecompute] = [
      sinon.spy(), sinon.spy(), sinon.spy(), sinon.spy(), sinon.spy()
    ];

    this.microstate = MicroState.create({
      default: {initial: 'state'},
      recompute: onRecompute
    });

    Ember.addListener(this.microstate, 'state', this, onStateEvent);
    Ember.addListener(this.microstate, 'custom', this, onCustomEvent);
    this.value = this.microstate.compute([], {'on-state': onState, 'on-custom': onCustom});
  });

  it("computes to the initial state ", function() {
    expect(this.value).to.deep.equal({initial: 'state'});
  });

  describe("setting the state with a custom event", function() {
    beforeEach(function() {
      this.microstate.setState('custom', ()=> ({totally: 'custom'}));
    });

    it("sets the new state", function() {
      expect(this.microstate.value).to.deep.equal({totally: 'custom'});
    });

    it("fires the 'state' event", function() {
      expect(onStateEvent.called).to.equal(true);
    });

    it("invokes the on-state callback", function() {
      expect(onState.calledWith({totally: 'custom'})).to.equal(true);
    });

    it("fires the 'custom' event", function() {
      expect(onCustomEvent.calledWith({totally: 'custom'})).to.equal(true);
    });

    it("invokes the on-custom callback", function() {
      expect(onCustom.calledWith({totally: 'custom'})).to.equal(true);
    });
  });


});<commit_msg>remove whitespace<commit_after>/* jshint expr:true */
import Ember from 'ember';
import { expect } from 'chai';
import { describe, beforeEach, it } from 'mocha';
import sinon from 'sinon';
import { MicroState } from 'ember-microstates';

describe.only('Microstates', function() {
  let onState = null;
  let onCustom = null;
  let onStateEvent = null;
  let onCustomEvent = null;
  let onRecompute = null;
  beforeEach(function() {
    [onState, onCustom, onStateEvent, onCustomEvent, onRecompute] = [
      sinon.spy(), sinon.spy(), sinon.spy(), sinon.spy(), sinon.spy()
    ];

    this.microstate = MicroState.create({
      default: {initial: 'state'},
      recompute: onRecompute
    });

    Ember.addListener(this.microstate, 'state', this, onStateEvent);
    Ember.addListener(this.microstate, 'custom', this, onCustomEvent);
    this.value = this.microstate.compute([], {'on-state': onState, 'on-custom': onCustom});
  });

  it("computes to the initial state ", function() {
    expect(this.value).to.deep.equal({initial: 'state'});
  });

  describe("setting the state with a custom event", function() {
    beforeEach(function() {
      this.microstate.setState('custom', ()=> ({totally: 'custom'}));
    });

    it("sets the new state", function() {
      expect(this.microstate.value).to.deep.equal({totally: 'custom'});
    });

    it("fires the 'state' event", function() {
      expect(onStateEvent.called).to.equal(true);
    });

    it("invokes the on-state callback", function() {
      expect(onState.calledWith({totally: 'custom'})).to.equal(true);
    });

    it("fires the 'custom' event", function() {
      expect(onCustomEvent.calledWith({totally: 'custom'})).to.equal(true);
    });

    it("invokes the on-custom callback", function() {
      expect(onCustom.calledWith({totally: 'custom'})).to.equal(true);
    });
  });
});
{'fraction_non_alphanumeric': 0.17761033369214208, 'fraction_numerical': 0.0, 'mean_word_length': 3.8907894736842104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2962252', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1187, 'n_words': 257}