|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 |
|
3 | 3 | import { |
| 4 | + createEmptyHybridClip, |
4 | 5 | createImportedAudioClipDraft, |
5 | 6 | createImportedAudioDisplayName, |
6 | 7 | createImportedAudioIds, |
| 8 | + getClipDeleteConfirmationMessage, |
| 9 | + toggleDrumStep, |
7 | 10 | validateImportedWavFile, |
8 | 11 | } from "../../../src/model"; |
9 | 12 |
|
@@ -81,4 +84,52 @@ describe("audio clip model", () => { |
81 | 84 | }, |
82 | 85 | }); |
83 | 86 | }); |
| 87 | + |
| 88 | + it("does not require confirmation for empty unused hybrid clips", () => { |
| 89 | + expect( |
| 90 | + getClipDeleteConfirmationMessage({ |
| 91 | + clip: createEmptyHybridClip({ id: "clip-1", name: "Clip 1" }), |
| 92 | + }), |
| 93 | + ).toBeNull(); |
| 94 | + }); |
| 95 | + |
| 96 | + it("requires confirmation for hybrid clips with musical events", () => { |
| 97 | + const clip = toggleDrumStep({ |
| 98 | + clip: createEmptyHybridClip({ id: "clip-1", name: "Clip 1" }), |
| 99 | + laneId: "kick", |
| 100 | + stepIndex: 0, |
| 101 | + }); |
| 102 | + |
| 103 | + expect(getClipDeleteConfirmationMessage({ clip })).toBe( |
| 104 | + "Delete Clip 1 and its musical events?", |
| 105 | + ); |
| 106 | + }); |
| 107 | + |
| 108 | + it("requires confirmation for hybrid clips used in the arrangement", () => { |
| 109 | + expect( |
| 110 | + getClipDeleteConfirmationMessage({ |
| 111 | + arrangementInstanceCount: 2, |
| 112 | + clip: createEmptyHybridClip({ id: "clip-1", name: "Clip 1" }), |
| 113 | + }), |
| 114 | + ).toBe("Delete Clip 1? 2 arrangement placements will also be removed."); |
| 115 | + }); |
| 116 | + |
| 117 | + it("includes arrangement removal in imported audio clip confirmation", () => { |
| 118 | + const { clip } = createImportedAudioClipDraft({ |
| 119 | + clipId: "audio-clip-loop", |
| 120 | + durationSeconds: 2.5, |
| 121 | + fileName: "Loop.wav", |
| 122 | + mimeType: "audio/wav", |
| 123 | + sampleId: "imported-audio-loop", |
| 124 | + }); |
| 125 | + |
| 126 | + expect( |
| 127 | + getClipDeleteConfirmationMessage({ |
| 128 | + arrangementInstanceCount: 1, |
| 129 | + clip, |
| 130 | + }), |
| 131 | + ).toBe( |
| 132 | + "Delete imported audio clip Loop? 1 arrangement placement will also be removed.", |
| 133 | + ); |
| 134 | + }); |
84 | 135 | }); |
0 commit comments