Skip to content

Commit 4cddaac

Browse files
committed
added insert clip at index and split within stacked track tests
1 parent 9c2ef79 commit 4cddaac

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

src/tracks/track/track.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,45 @@ describe('The Track Object', () => {
5757
expect(track.clips.at(2)?.stop.frames).toBe(12);
5858
});
5959

60+
it('should be able to add clips at an index, if stacked', async () => {
61+
track.stacked();
62+
63+
await track.add(new Clip({ stop: 10, start: 0 }));
64+
await track.add(new Clip({ stop: 10, start: 0 }));
65+
await track.add(new Clip({ stop: 10, start: 0 }));
66+
67+
expect(track.clips.length).toBe(3);
68+
expect(track.start.frames).toBe(0);
69+
expect(track.stop.frames).toBe(30);
70+
71+
await track.add(new Clip({ stop: 2, start: 0 }), 1);
72+
73+
expect(track.clips[0].start.frames).toBe(0);
74+
expect(track.clips[0].stop.frames).toBe(10);
75+
76+
expect(track.clips[1].start.frames).toBe(10);
77+
expect(track.clips[1].stop.frames).toBe(12);
78+
79+
expect(track.clips[2].start.frames).toBe(12);
80+
expect(track.clips[2].stop.frames).toBe(22);
81+
82+
await track.add(new Clip({ stop: 15, start: 10 }), 4);
83+
84+
expect(track.clips[0].start.frames).toBe(0);
85+
expect(track.clips[0].stop.frames).toBe(10);
86+
87+
expect(track.clips[4].start.frames).toBe(32);
88+
expect(track.clips[4].stop.frames).toBe(37);
89+
90+
await track.clips[0].split(5);
91+
92+
expect(track.clips[0].start.frames).toBe(0);
93+
expect(track.clips[0].stop.frames).toBe(5);
94+
95+
expect(track.clips[1].start.frames).toBe(5);
96+
expect(track.clips[1].stop.frames).toBe(10);
97+
});
98+
6099
it('should snap the clip when it overlaps with the end of another clip', async () => {
61100
const clip0 = new Clip({ stop: 20, start: 0 });
62101
const clip1 = new Clip({ stop: 30, start: 11 });

src/tracks/track/track.strategies.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,23 @@ describe('The Track Strategy Object (stack mode)', () => {
244244
expect(track.clips[2].start.frames).toBe(30);
245245
expect(track.clips[2].stop.frames).toBe(39);
246246
});
247+
248+
it('should insert clips a specified index', () => {
249+
const track = createDefaultTrack();
250+
track.stacked();
251+
252+
expect(track.clips[0].stop.frames).toBe(10);
253+
expect(track.clips[1].stop.frames).toBe(30);
254+
expect(track.clips[2].stop.frames).toBe(39);
255+
256+
strategy.add(new Clip({ start: 20, stop: 25 }), track, 1);
257+
258+
expect(track.clips[0].stop.frames).toBe(10);
259+
expect(track.clips[1].start.frames).toBe(10);
260+
expect(track.clips[1].stop.frames).toBe(15);
261+
expect(track.clips[2].start.frames).toBe(15);
262+
expect(track.clips[2].stop.frames).toBe(35);
263+
});
247264
});
248265

249266
function createDefaultTrack(): Track<Clip> {

0 commit comments

Comments
 (0)