<commit_before>/**
 * uproxySpec.js
 *
 * There are a number of message types and interactions which prepare the
 * roster, clients, and instances. These have various caveats and edge cases,
 * and can also be received in different orders. This file lays out these
 * requirement and ensures consistency.
 */

var uproxy = this;        // Remember global uproxy context so spyOn works.
var state = store.state;  // Depends on state-storage.js.

describe("uproxy.updateUser", function() {

  // Stub out communications functions.
  beforeEach(function() {
    spyOn(uproxy, 'sendInstance');
  });

  it('does add user to roster.', function() {
    // Add a normal, non-UProxy client user.
    var normalAlice = {
      userId: '<EMAIL>',
      name: 'Alice No UProxy',
      clients: {
        '<EMAIL>/normal12345': {
          clientId: '<EMAIL>/normal12345',
          network: 'magic',
          status: 'messageable'
        }
      }
    };
    var count = Object.keys(store.state.roster).length;
    var userId = normalAlice.userId;
    expect(state.roster[userId]).toBeUndefined();
    updateUser(normalAlice);
    expect(state.roster[userId]).toBeDefined();
    expect(Object.keys(state.roster).length).toBe(count + 1);
    expect(store.state.roster[userId]).toEqual({
      userId: '<EMAIL>',
      name: 'Alice No UProxy',
      clients: {
        '<EMAIL>/normal12345': {
          clientId: '<EMAIL>/normal12345',
          network: 'magic',
          status: 'messageable'
        }
      },
      canUProxy: false,
      onGoogle: false,
      onFB: false,
      imageData: {},
      url: ''
    });
  });

  it('calls sendInstance for uproxy-enabled users', function() {
    // Add a user with an active 'uproxy' client, and ensure that we send her
    // our instance data.
    var wonderAlice = {
      userId: '<EMAIL>@censored.nationstate',
      name: 'Alice UProxy',
      clients: {
        '<EMAIL>/uproxy1337': {
          clientId: '<EMAIL>/uproxy1337',
          network: 'magic',
          status: 'messageable'
        }
      }
    };
    updateUser(wonderAlice);
    var aliceClient = {<commit_msg>broken unit test<commit_after>/**
 * uproxySpec.js
 *
 * There are a number of message types and interactions which prepare the
 * roster, clients, and instances. These have various caveats and edge cases,
 * and can also be received in different orders. This file lays out these
 * requirement and ensures consistency.
 */

var uproxy = this;        // Remember global uproxy context so spyOn works.
var state = store.state;  // Depends on state-storage.js.

describe("uproxy.updateUser", function() {

  // Stub out communications functions.
  beforeEach(function() {
    spyOn(uproxy, 'sendInstance');
  });

  it('does add user to roster.', function() {
    // Add a normal, non-UProxy client user.
    var normalAlice = {
      userId: '<EMAIL>',
      name: 'Alice No UProxy',
      clients: {
        '<EMAIL>/normal12345': {
          clientId: '<EMAIL>/normal12345',
          network: 'magic',
          status: 'messageable'
        }
      }
    };
    var count = Object.keys(store.state.roster).length;
    var userId = normalAlice.userId;
    expect(state.roster[userId]).toBeUndefined();
    updateUser(normalAlice);
    expect(state.roster[userId]).toBeDefined();
    expect(Object.keys(state.roster).length).toBe(count + 1);
    expect(store.state.roster[userId]).toEqual({
      userId: '<EMAIL>',
      name: 'Alice No UProxy',
      clients: {
        '<EMAIL>/normal12345': {
          clientId: '<EMAIL>/normal12345',
          network: 'magic',
          status: 'messageable'
        }
      },
      canUProxy: false,
      onGoogle: false,
      onFB: false,
      imageData: '',
      url: ''
    });
  });

  it('calls sendInstance for uproxy-enabled users', function() {
    // Add a user with an active 'uproxy' client, and ensure that we send her
    // our instance data.
    var wonderAlice = {
      userId: '<EMAIL>',
      name: 'Alice UProxy',
      clients: {
        '<EMAIL>/uproxy1337': {
          clientId: '<EMAIL>/uproxy1337',
          network: 'magic',
          status: 'messageable'
        }
      }
    };
    updateUser(wonderAlice);
    var aliceClient = {
{'fraction_non_alphanumeric': 0.1316658801321378, 'fraction_numerical': 0.01368570080226522, 'mean_word_length': 2.451954397394137, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '3497134', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1303, 'n_words': 342}