mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-09 02:18:57 +00:00
43 lines
980 B
TypeScript
43 lines
980 B
TypeScript
|
import { expect } from "chai";
|
||
|
import { Offline } from "test/helper/Offline";
|
||
|
import { Transport } from "./Transport";
|
||
|
import { TransportEvent } from "./TransportEvent";
|
||
|
|
||
|
describe("TransportEvent", () => {
|
||
|
|
||
|
it("can be created and disposed", () => {
|
||
|
return Offline((context) => {
|
||
|
const transport = new Transport({context});
|
||
|
const event = new TransportEvent(transport, {
|
||
|
time: 0,
|
||
|
});
|
||
|
event.dispose();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it("has a unique id", () => {
|
||
|
return Offline((context) => {
|
||
|
const transport = new Transport({context});
|
||
|
const event = new TransportEvent(transport, {
|
||
|
time: 0,
|
||
|
});
|
||
|
expect(event.id).to.be.a("number");
|
||
|
event.dispose();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it("can invoke the callback", (done) => {
|
||
|
Offline((context) => {
|
||
|
const transport = new Transport({context});
|
||
|
const event = new TransportEvent(transport, {
|
||
|
callback: (time) => {
|
||
|
expect(time).to.equal(100);
|
||
|
done();
|
||
|
},
|
||
|
time: 0,
|
||
|
});
|
||
|
event.invoke(100);
|
||
|
});
|
||
|
});
|
||
|
});
|