<commit_before>describe("fdom.proxy.APIInterface", function() {
  var emit, reg, api;
  beforeEach(function() {
        var iface = {
      'test': {'type': 'method', 'value': ['string']},
      'ev': {'type': 'event', 'value': 'string'},
      'co': {'type': 'constant', 'value': '12'}
    };
    emit = jasmine.createSpy('emit');
    var onMsg = function(obj, r) {
      reg = r;
    };
    api = new fdom.proxy.ApiInterface(iface, onMsg, emit);
  });

  it("Creates an object looking like an interface.", function() {
    expect(typeof(api.test)).toEqual('function');
    expect(typeof(api.on)).toEqual('function');
    expect(api.co).toEqual('12');

    expect(emit).not.toHaveBeenCalledWith({
      'action': 'construct'
    });
    var promise = api.test('hi');
    expect(emit).toHaveBeenCalledWith({
      action: 'method',
      type: 'test',
      reqId: 0,
      value: ['hi'] });

    var spy = jasmine.createSpy('ret');
    promise.done(spy);
    expect(spy).not.toHaveBeenCalled();

    reg('message', {
      type: 'method',
      reqId: 0,
      value: 'boo!'
    });
    expect(spy).toHaveBeenCalledWith('boo!');
  });

  it("delivers events", function() {
    var cb = jasmine.createSpy('cb');
    api.on('ev', cb);
    expect(cb).not.toHaveBeenCalled();

    reg('message', {
      'type': 'event',
      'name': 'ev',
      'value': 'boo!'
    });
    expect(cb).toHaveBeenCalledWith('boo!');
  });
});

describe("fdom.proxy.conform", function() {
  it("Conforms Simple values to templates", function() {
    var blob = null;<commit_msg>Fixed: spec/proxyAPIInterfaceSpec.js not cleaning up iframes after tests.<commit_after>describe("fdom.proxy.APIInterface", function() {
  var emit, reg, api;
  beforeEach(function() {
        var iface = {
      'test': {'type': 'method', 'value': ['string']},
      'ev': {'type': 'event', 'value': 'string'},
      'co': {'type': 'constant', 'value': '12'}
    };
    emit = jasmine.createSpy('emit');
    var onMsg = function(obj, r) {
      reg = r;
    };
    api = new fdom.proxy.ApiInterface(iface, onMsg, emit);
  });

  it("Creates an object looking like an interface.", function() {
    expect(typeof(api.test)).toEqual('function');
    expect(typeof(api.on)).toEqual('function');
    expect(api.co).toEqual('12');

    expect(emit).not.toHaveBeenCalledWith({
      'action': 'construct'
    });
    var promise = api.test('hi');
    expect(emit).toHaveBeenCalledWith({
      action: 'method',
      type: 'test',
      reqId: 0,
      value: ['hi'] });

    var spy = jasmine.createSpy('ret');
    promise.done(spy);
    expect(spy).not.toHaveBeenCalled();

    reg('message', {
      type: 'method',
      reqId: 0,
      value: 'boo!'
    });
    expect(spy).toHaveBeenCalledWith('boo!');
  });

  it("delivers events", function() {
    var cb = jasmine.createSpy('cb');
    api.on('ev', cb);
    expect(cb).not.toHaveBeenCalled();

    reg('message', {
      'type': 'event',
      'name': 'ev',
      'value': 'boo!'
    });
    expect(cb).toHaveBeenCalledWith('boo!');
  });
});

afterEach(function() {
  var frames = document.getElementsByTagName('iframe');
  for (var i = 0; i < frames.length; i++) {
    frames[i].parentNode.removeChild(frames[i]);
  }
});

describe("fdom.proxy.conform", function() {
  it("Conforms Simple values to templates", function() {
    var blob = null;
{'fraction_non_alphanumeric': 0.2020864381520119, 'fraction_numerical': 0.0038748137108792846, 'mean_word_length': 3.158612143742255, 'pattern_counts': {'":': 0, '<': 4, '<?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': '4486492', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1140, 'n_words': 226}