{"size": 1472, "ext": "js", "max_stars_repo_path": "test/api/IIRFilterNode.js", "max_stars_repo_name": "mohayonao/web-audio-engine", "max_stars_repo_stars_event_min_datetime": "2016-03-29T12:32:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-18T11:25:05.000Z", "max_issues_repo_path": "test/api/IIRFilterNode.js", "max_issues_repo_name": "mohayonao/web-audio-engine", "max_issues_repo_issues_event_min_datetime": "2016-05-03T01:17:47.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-28T02:17:48.000Z", "max_forks_repo_path": "test/api/IIRFilterNode.js", "max_forks_repo_name": "mohayonao/web-audio-engine", "max_forks_repo_forks_event_min_datetime": "2016-03-30T09:28:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-10T09:03:52.000Z"}
{"max_stars_count": 237, "max_issues_count": 22, "max_forks_count": 31, "avg_line_length": 36.8, "max_line_length": 80, "alphanum_fraction": 0.6881793478}
"use strict";

require("run-with-mocha");

const assert = require("assert");
const sinon = require("sinon");
const api = require("../../src/api");
const AudioContext = require("../../src/api/BaseAudioContext");

describe("api/IIRFilterNode", () => {
  it("context.createIIRFilter(feedforward, feedback)", () => {
    const context = new AudioContext();
    const feedforward = new Float32Array(4);
    const feedback = new Float32Array(4);
    const target = context.createIIRFilter(feedforward, feedback);

    assert(target instanceof api.IIRFilterNode);
  });

  describe("methods", () => {
    it(".getFrequencyResponse(frequencyHz, magResponse, phaseResponse)", () => {
      const context = new AudioContext();
      const feedforward = new Float32Array(4);
      const feedback = new Float32Array(4);
      const target = context.createIIRFilter(feedforward, feedback);
      const frequencyHz = new Float32Array(128);
      const magResponse = new Float32Array(128);
      const phaseResponse = new Float32Array(128);

      target._impl.getFrequencyResponse = sinon.spy();

      target.getFrequencyResponse(frequencyHz, magResponse, phaseResponse);
      assert(target._impl.getFrequencyResponse.callCount === 1);
      assert(target._impl.getFrequencyResponse.args[0][0] === frequencyHz);
      assert(target._impl.getFrequencyResponse.args[0][1] === magResponse);
      assert(target._impl.getFrequencyResponse.args[0][2] === phaseResponse);
    });
  });
});
