<commit_before>import { BasicTests } from "test/helper/Basic";
import { Noise } from "./Noise";
import { expect } from "chai";
import { SourceTests } from "test/helper/SourceTests";
import { OutputAudio } from "test/helper/OutputAudio";
import { CompareToFile } from "test/helper/CompareToFile";

describe("Noise", () => {

	// run the common tests
	BasicTests(Noise);
	SourceTests(Noise);

	it("matches a file",  () => {
		return CompareToFile(() => {
			const noise = new Noise().toMaster();
			noise.start(0.1).stop(0.2);
		}, "noise.wav", 9);
	});

	context("Get/Set", () => {

		it("can be constructed with an options object", () => {
			const noise = new Noise({
				type: "brown",
			});
			expect(noise.type).to.equal("brown");
			noise.dispose();
		});

		it("can set the playbackRate in the constructor", () => {
			const noise = new Noise({
				playbackRate: 2,
			});
			expect(noise.playbackRate).to.equal(2);
			noise.dispose();
		});

		it("can set the playbackRate after the noise is started", () => {
			return OutputAudio(() => {
				const noise = new Noise().toMaster();
				noise.start();
				noise.playbackRate = 3;
				expect(noise.playbackRate).to.equal(3);
			});
		});

	});

	context("Type", () => {

		it("can be set to 3 noise types", () => {
			const noise = new Noise();
			const types = ["white", "brown", "pink"];
			types.forEach(type => {
				// @ts-ignore
				noise.type = type;
				expect(noise.type).to.equal(type);
			});
			noise.dispose();
		});

		it("cant set invalid type", () => {
			const noise = new Noise();
			expect(() => {
				// @ts-ignore
				noise.type = "else";
			}).to.throw(Error);
			noise.dispose();
		});

		it("outputs white noise", () => {
			return OutputAudio(() => {
				const noise = new Noise("white");
				noise.toMaster();
				noise.start();
			});
		});

		it("outputs pink noise", () => {
			return OutputAudio(() => {
				const noise = new Noise("pink");
				noise.toMaster();
				noise.start();
			});
		});

		it("outputs brown noise", () => {
			return OutputAudio(() => {
				const noise = new Noise("brown");
				noise.toMaster();
				noise.start();
			});
		});

		it("can set the type after the noise is started", () => {
			return OutputAudio(() => {
				const noise = new Noise();
				noise.toMaster();
				noise.start();
				noise.type = "brown";
			});
		});
	});
});
<commit_msg>linting<commit_after>import { expect } from "chai";
import { BasicTests } from "test/helper/Basic";
import { CompareToFile } from "test/helper/CompareToFile";
import { OutputAudio } from "test/helper/OutputAudio";
import { SourceTests } from "test/helper/SourceTests";
import { Noise } from "./Noise";

describe("Noise", () => {

	// run the common tests
	BasicTests(Noise);
	SourceTests(Noise);

	it("matches a file",  () => {
		return CompareToFile(() => {
			const noise = new Noise().toMaster();
			noise.start(0.1).stop(0.2);
		}, "noise.wav", 9);
	});

	context("Get/Set", () => {

		it("can be constructed with an options object", () => {
			const noise = new Noise({
				type: "brown",
			});
			expect(noise.type).to.equal("brown");
			noise.dispose();
		});

		it("can set the playbackRate in the constructor", () => {
			const noise = new Noise({
				playbackRate: 2,
			});
			expect(noise.playbackRate).to.equal(2);
			noise.dispose();
		});

		it("can set the playbackRate after the noise is started", () => {
			return OutputAudio(() => {
				const noise = new Noise().toMaster();
				noise.start();
				noise.playbackRate = 3;
				expect(noise.playbackRate).to.equal(3);
			});
		});

	});

	context("Type", () => {

		it("can be set to 3 noise types", () => {
			const noise = new Noise();
			const types = ["white", "brown", "pink"];
			types.forEach(type => {
				// @ts-ignore
				noise.type = type;
				expect(noise.type).to.equal(type);
			});
			noise.dispose();
		});

		it("cant set invalid type", () => {
			const noise = new Noise();
			expect(() => {
				// @ts-ignore
				noise.type = "else";
			}).to.throw(Error);
			noise.dispose();
		});

		it("outputs white noise", () => {
			return OutputAudio(() => {
				const noise = new Noise("white");
				noise.toMaster();
				noise.start();
			});
		});

		it("outputs pink noise", () => {
			return OutputAudio(() => {
				const noise = new Noise("pink");
				noise.toMaster();
				noise.start();
			});
		});

		it("outputs brown noise", () => {
			return OutputAudio(() => {
				const noise = new Noise("brown");
				noise.toMaster();
				noise.start();
			});
		});

		it("can set the type after the noise is started", () => {
			return OutputAudio(() => {
				const noise = new Noise();
				noise.toMaster();
				noise.start();
				noise.type = "brown";
			});
		});
	});
});

{'fraction_non_alphanumeric': 0.2038135593220339, 'fraction_numerical': 0.00423728813559322, 'mean_word_length': 2.9638958858102433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 45, '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': '206934', 'n_tokens_mistral': 1950, 'n_tokens_neox': 1543, 'n_words': 364}