<commit_before>/**
 * freedom-mocks.ts
 *
 * This file must be compiled independently of all other typescript in uProxy.
 */

/// <reference path='../third_party/typings/es6-promise/es6-promise.d.ts' />


class MockCore {

  public createChannel = () => {
    return Promise.resolve({ identifier: 'unused' });
  }

  public bindChannel = (id:string) => {
    return Promise.resolve(null);
  }

  public getId = () => { return ['useless']; }

}  // class MockCore

class MockCorePeerConnection {

  public createOffer = () => {
    var mockDesc = {
      sdp: 'a=fingerprint:sha-256 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:' +
          'EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF '
    };
    return Promise.resolve(mockDesc);
  }

  public setup = () => {
    console.log('[MockCorePeerConnection] setup');
  }

}  // class MockPeerConnection

class MockStorage {

  private store_;

  constructor(init_store) {
    this.store_ = init_store;
  }

  public keys = () => {
    return Object.keys(this.store_);
  }

  public get = (key) => {
    var v = this.store_[key];
    console.log('[MockStorage] get ' + key);
    if (v) {
      return Promise.resolve(v);
    }
    return Promise.reject('non-existing key');
  }

  public set = (key, value) => {
    var prev = this.store_[key];
    this.store_[key] = value;
    console.log('[MockStorage] set ' + key + ' : ' + value);
    return Promise.resolve(prev);
  }

  public remove = (key) => {
    //console.log("\n  public remove(" + key + ").");
    var prev = this.store_[key];
    delete this.store_[key];
    return Promise.resolve(prev);
  }

  public clear = () => {
    this.store_ = {};
    return Promise.resolve();
  }

}  // class MockStorage

class MockChannel {

  public on = (eventTypeString, callback) => {
    return null;
  }

  public emit = (eventTypeString, value) => {
    return null;
  }

}

class MockSocial {
  public on = () => {}
  public emit = () => {}
}

class MockLog {
}

var freedom = MockChannel;
freedom['storage'] = () => { return new MockStorage({}); };
var mockSocial = () => { return new MockSocial(); };
mockSocial['api'] = 'social';
mockSocial['manifest'] = 'I have no manifest :)';

freedom['core'] = () => { return new MockCore(); };
freedom['core.console'] = () => { return new MockLog(); };
freedom['core.peerconnection'] = () => { return new MockCorePeerConnection(); };
freedom['SOCIAL-websocket'] = mockSocial;

var DEBUG = true;

var log = console;<commit_msg>fix test<commit_after>/**
 * freedom-mocks.ts
 *
 * This file must be compiled independently of all other typescript in uProxy.
 */

/// <reference path='../third_party/typings/es6-promise/es6-promise.d.ts' />


class MockCore {

  public createChannel = () => {
    return Promise.resolve({ identifier: 'unused' });
  }

  public bindChannel = (id:string) => {
    return Promise.resolve(null);
  }

  public getId = () => { return ['useless']; }

}  // class MockCore

class MockCorePeerConnection {

  public createOffer = () => {
    var mockDesc = {
      sdp: 'a=fingerprint:sha-256 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:' +
          'EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF '
    };
    return Promise.resolve(mockDesc);
  }

  public setup = () => {
    console.log('[MockCorePeerConnection] setup');
  }

}  // class MockPeerConnection

class MockStorage {

  private store_;

  constructor(init_store) {
    this.store_ = init_store;
  }

  public keys = () => {
    return Object.keys(this.store_);
  }

  public get = (key) => {
    var v = this.store_[key];
    console.log('[MockStorage] get ' + key);
    if (v) {
      return Promise.resolve(v);
    }
    return Promise.reject('non-existing key');
  }

  public set = (key, value) => {
    var prev = this.store_[key];
    this.store_[key] = value;
    console.log('[MockStorage] set ' + key + ' : ' + value);
    return Promise.resolve(prev);
  }

  public remove = (key) => {
    //console.log("\n  public remove(" + key + ").");
    var prev = this.store_[key];
    delete this.store_[key];
    return Promise.resolve(prev);
  }

  public clear = () => {
    this.store_ = {};
    return Promise.resolve();
  }

}  // class MockStorage

class MockChannel {

  public on = (eventTypeString, callback) => {
    return null;
  }

  public emit = (eventTypeString, value) => {
    return null;
  }

}

class MockSocial {
  public on = () => {}
  public emit = () => {}
}

class MockLog {
}

var freedom = MockChannel;
freedom['storage'] = () => { return new MockStorage({}); };
var mockSocial = () => { return new MockSocial(); };
mockSocial['api'] = 'social';
mockSocial['manifest'] = 'I have no manifest :)';

freedom['core'] = () => { return new MockCore(); };
freedom['core.console'] = () => { return new MockLog(); };
freedom['core.rtcpeerconnection'] = () => { return new MockCorePeerConnection(); };
freedom['SOCIAL-websocket'] = mockSocial;

var DEBUG = true;

var log = console;
{'fraction_non_alphanumeric': 0.17913465426607358, 'fraction_numerical': 0.01819652244237768, 'mean_word_length': 3.1782094594594597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '3920263', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1651, 'n_words': 354}