Skip to content

Commit 99f1317

Browse files
authored
Add files via upload
1 parent 42f8f51 commit 99f1317

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

js/utils/__tests__/synthutils.test.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,35 +209,35 @@ describe("Utility Functions (logic-only)", () => {
209209
expect(instruments[turtle]["electronic synth"]).toBeInstanceOf(Tone.PolySynth)
210210
});
211211
it("it should creates a amsynth based on the specified parameters, either using samples, built-in synths, or custom synths", () => {
212-
let instrumentName = "guitar"
212+
let instrumentName = "poly"
213213
__createSynth(turtle, instrumentName, "amsynth", {});
214214
expect(instruments[turtle][instrumentName]).toBeInstanceOf(Tone.AMSynth)
215215
});
216216

217217
it("it should creates a CUSTOMSAMPLES based on the specified parameters, either using samples, built-in synths, or custom synths", () => {
218218
CUSTOMSAMPLES['pianoC4'] = "pianoC4";
219219
CUSTOMSAMPLES['drumKick'] = "drumKick";
220-
let instrumentName = "guitar"
220+
let instrumentName = "piano"
221221
__createSynth(turtle, instrumentName, "pianoC4", {});
222222
expect(instruments[turtle][instrumentName]).toBeInstanceOf(Tone.Sampler)
223223
});
224224

225225
it("it should creates a CUSTOMSAMPLES based on the specified parameters, either using samples, built-in synths, or custom synths", () => {
226-
let instrumentName = "guitar"
227-
let sourceName = "http://testing.com"
226+
let instrumentName = "drumKick"
227+
let sourceName = "http://example.com/drumKick.wav"
228228
__createSynth(turtle, instrumentName, sourceName, {});
229229
expect(instruments[turtle][sourceName]["noteDict"]).toBe(sourceName)
230230
expect(instrumentsSource[instrumentName]).toStrictEqual([1, 'drum'])
231231
});
232232
it("it should creates a CUSTOMSAMPLES based on the specified parameters, either using samples, built-in synths, or custom synths", () => {
233233
let instrumentName = "guitar"
234-
let sourceName = "file://testing.jpg"
234+
let sourceName = "file://testing.wav"
235235
__createSynth(turtle, instrumentName, sourceName, {});
236236
expect(instruments[turtle][sourceName]["noteDict"]).toBe(sourceName)
237237
expect(instrumentsSource[instrumentName]).toStrictEqual([1, 'drum'])
238238
});
239239
it("it should creates a CUSTOMSAMPLES based on the specified parameters, either using samples, built-in synths, or custom synths", () => {
240-
let instrumentName = "guitar"
240+
let instrumentName = "snare drum"
241241
let sourceName = "drum"
242242
__createSynth(turtle, instrumentName, sourceName, {});
243243
expect(instrumentsSource[instrumentName]).toStrictEqual([1, 'drum'])
@@ -553,9 +553,9 @@ describe("Utility Functions (logic-only)", () => {
553553

554554
test('should call start() for drum instruments', () => {
555555
// Arrange
556-
const instrumentName = 'guitar';
556+
const instrumentName = 'guitar'; // Assuming 'snare' is a drum
557557
const note = 'C4';
558-
558+
559559
// Act
560560
startSound(turtle, instrumentName, note);
561561

@@ -564,6 +564,7 @@ describe("Utility Functions (logic-only)", () => {
564564
expect(instruments[turtle][instrumentName].triggerAttack).not.toHaveBeenCalled();
565565
});
566566

567+
567568
test('should call triggerAttack() for non-drum instruments', () => {
568569
// Arrange
569570
const instrumentName = 'flute';
@@ -1029,7 +1030,7 @@ describe("Utility Functions (logic-only)", () => {
10291030
it("it should creates a synth based on the user's input in the 'Timbre' clamp, handling race conditions with the samples loader.", () => {
10301031
const turtle = "turtle1"; // Use const or let
10311032
const instrumentName = "piano"; // Localize declaration
1032-
const sourceName = "voiceSample1"; // Localize declaration
1033+
const sourceName = "voice recording"; // Localize declaration
10331034
expect(createSynth(turtle, instrumentName, sourceName, {})).toBe(undefined);
10341035
});
10351036
});

js/utils/__tests__/tonemock.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class Synth {
5656
constructor(synthOptions) {
5757
this.synthOptions = synthOptions
5858
this.triggerAttackRelease = jest.fn().mockReturnThis();
59+
this.stop = jest.fn().mockReturnThis(); // Ensure stop is mocked here
60+
this.triggerAttack = jest.fn().mockReturnThis(); // new
61+
this.triggerRelease = jest.fn().mockReturnThis(); // new
62+
this.start = jest.fn().mockReturnThis(); // new
5963
this.chain = jest.fn().mockReturnThis();
6064
this.volume = {
6165
value: 0,

0 commit comments

Comments
 (0)