making sure that draw/transport/destination are disposed when the context is closed

This commit is contained in:
Yotam Mann 2019-10-31 11:41:21 -04:00
parent 258b10a63f
commit 91ae308e66

View file

@ -6,12 +6,27 @@ import { Transport } from "../clock/Transport";
import { getContext } from "../Global";
import { createAudioContext } from "./AudioContext";
import { Context } from "./Context";
// import it for the side effects
import "./Destination";
import { Destination } from "./Destination";
import { Draw } from "../util/Draw";
import { connect } from "./ToneAudioNode";
describe("Context", () => {
it("creates and disposes the classes attached to the context", async () => {
const ac = new AudioContext();
const context = new Context(ac);
const ctxDest = context.destination;
const ctxDraw = context.draw;
const ctxTransport = context.transport;
expect(context.destination).is.instanceOf(Destination);
expect(context.draw).is.instanceOf(Draw);
await context.close();
expect(ctxDest.disposed).to.be.true;
expect(ctxDraw.disposed).to.be.true;
expect(ctxTransport.disposed).to.be.true;
context.dispose();
});
context("AudioContext", () => {
it("extends the AudioContext methods", () => {
@ -74,9 +89,8 @@ describe("Context", () => {
expect(context.state).to.equal("suspended");
await context.resume();
expect(context.state).to.equal("running");
expect(context.destination).to.exist;
context.dispose();
return ac.close();
return context.close();
});
it("invokes the statechange event", async () => {