Skip to content

Commit fcdfd8e

Browse files
committed
removed frame type casting
1 parent bb62428 commit fcdfd8e

File tree

12 files changed

+108
-120
lines changed

12 files changed

+108
-120
lines changed

src/clips/clip/clip.spec.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { Timestamp } from '../../models';
1111
import { Composition } from '../../composition';
1212
import { Track } from '../../tracks';
1313

14-
import type { frame } from '../../types';
15-
1614
describe('The Clip Object', () => {
1715
const updateFn = vi.fn();
1816
const detachFn = vi.fn();
@@ -44,7 +42,7 @@ describe('The Clip Object', () => {
4442
});
4543

4644
it('should have setters that trigger an update', () => {
47-
clip.set({ stop: <frame>200, start: <frame>100 });
45+
clip.set({ stop: 200, start: 100 });
4846

4947
expect(clip.start.frames).toBe(100);
5048
expect(clip.stop.frames).toBe(200);
@@ -53,14 +51,14 @@ describe('The Clip Object', () => {
5351
});
5452

5553
it('should should set start and stop if the start is larger than the stop', () => {
56-
clip.set({ stop: <frame>40, start: <frame>60 });
54+
clip.set({ stop: 40, start: 60 });
5755

5856
// 1ms more than start;
5957
expect(clip.start.millis).toBe(2000);
6058
expect(clip.stop.millis).toBe(2001);
6159

6260
// 1ms less than stop
63-
clip.set({ stop: <frame>35 });
61+
clip.set({ stop: 35 });
6462
expect(clip.stop.millis).toBe(1167);
6563
expect(clip.start.millis).toBe(1166);
6664

@@ -69,7 +67,7 @@ describe('The Clip Object', () => {
6967
});
7068

7169
it('should connect to a track', async () => {
72-
clip.set({ stop: <frame>60, start: <frame>30 });
70+
clip.set({ stop: 60, start: 30 });
7371

7472
const composition = new Composition();
7573
const track = composition.createTrack('base');
@@ -126,24 +124,24 @@ describe('The Clip Object', () => {
126124
});
127125

128126
it('should be offset by a given frame', async () => {
129-
clip.set({ stop: <frame>120, start: <frame>100, name: 'foo' });
127+
clip.set({ stop: 120, start: 100, name: 'foo' });
130128

131129
const composition = new Composition();
132130
const track = composition.createTrack('base');
133131
await track.add(clip);
134-
await track.add(new Clip({ stop: <frame>80, start: <frame>60 }));
132+
await track.add(new Clip({ stop: 80, start: 60 }));
135133

136134
expect(track.clips.length).toBe(2);
137135
expect(track.clips[1].name).toBe('foo');
138136

139-
clip.offsetBy(<frame>-80);
137+
clip.offsetBy(-80);
140138

141139
expect(track.clips.length).toBe(2);
142140
expect(track.clips[0].name).toBe('foo');
143141
expect(track.clips[0].start.frames).toBe(20);
144142
expect(track.clips[0].stop.frames).toBe(40);
145143

146-
clip.offsetBy(<frame>30);
144+
clip.offsetBy(30);
147145

148146
expect(track.clips.length).toBe(2);
149147
expect(track.clips[0].name).toBe('foo');

src/clips/media/media.spec.ts

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import { Font, TextClip } from '../text';
1515
import { ValidationError } from '../../errors';
1616
import { VisualMixin, VisualMixinProps } from '../mixins';
1717
import { MediaClip } from './media';
18-
19-
import type { frame, MixinType } from '../../types';
18+
import { MixinType } from '../../types';
2019

2120
describe('The Media Clip', () => {
2221
const mockFn = vi.fn();
@@ -51,22 +50,22 @@ describe('The Media Clip', () => {
5150
});
5251

5352
it('should be able to cut a clip with subclip', () => {
54-
clip.duration.frames = <frame>600;
53+
clip.duration.frames = 600;
5554
expect(clip.duration.frames).toBe(600);
5655
expect(clip.range[0].frames).toBe(0);
5756
// range 1 is using the duration timestamp by reference
5857
expect(clip.range[1].frames).toBe(600);
59-
clip.subclip(<frame>30, <frame>360);
58+
clip.subclip(30, 360);
6059
expect(frameFn).toBeCalledTimes(1);
6160
expect(clip.range[0].frames).toBe(30);
6261
expect(clip.range[1].frames).toBe(360);
6362
});
6463

6564
it('should lead to correct frames in combination with the offset', () => {
66-
clip.duration.frames = <frame>300;
67-
clip.set({ offset: <frame>150 });
65+
clip.duration.frames = 300;
66+
clip.set({ offset: 150 });
6867
expect(frameFn).toBeCalledTimes(1);
69-
clip.subclip(<frame>30, <frame>100);
68+
clip.subclip(30, 100);
7069
expect(frameFn).toBeCalledTimes(2);
7170
expect(clip.range[0].frames).toBe(30);
7271
expect(clip.range[1].frames).toBe(100);
@@ -75,45 +74,45 @@ describe('The Media Clip', () => {
7574
});
7675

7776
it('should not be possible to clip outside the duration boundaries', () => {
78-
clip.duration.frames = <frame>20;
79-
clip.subclip(<frame>-5, <frame>25);
77+
clip.duration.frames = 20;
78+
clip.subclip(-5, 25);
8079
expect(clip.range[0].frames).toBe(0);
8180
expect(clip.range[1].frames).toBe(20);
8281
});
8382

8483
it('should not be possible to reverse the upper and lower bound', () => {
85-
expect(() => clip.subclip(<frame>10, <frame>5)).toThrowError();
84+
expect(() => clip.subclip(10, 5)).toThrowError();
8685
});
8786

8887
it('should be possible to set either the upper or the lower bound', () => {
89-
clip.duration.frames = <frame>20;
90-
clip.subclip(undefined, <frame>15);
88+
clip.duration.frames = 20;
89+
clip.subclip(undefined, 15);
9190
expect(clip.range[1].frames).toBe(15);
92-
clip.subclip(<frame>5);
91+
clip.subclip(5);
9392
expect(clip.range[0].frames).toBe(5);
9493
});
9594

9695
it('should be adapt the lower slice when setting start', () => {
97-
clip.duration.frames = <frame>20;
98-
clip.subclip(<frame>5, <frame>15);
99-
clip.set({ offset: <frame>5 });
96+
clip.duration.frames = 20;
97+
clip.subclip(5, 15);
98+
clip.set({ offset: 5 });
10099
expect(clip.duration.frames).toBe(20);
101100
expect(clip.start.frames).toBe(10);
102101
expect(clip.stop.frames).toBe(20);
103102
// case in valid range
104-
clip.set({ start: <frame>15 });
103+
clip.set({ start: 15 });
105104
expect(clip.start.frames).toBe(15);
106105
expect(clip.offset.frames).toBe(5);
107106
expect(clip.range[0].frames).toBe(10);
108107
expect(clip.range[1].frames).toBe(15);
109108
// lower than min range
110-
clip.set({ start: <frame>4 });
109+
clip.set({ start: 4 });
111110
expect(clip.start.frames).toBe(5);
112111
expect(clip.offset.frames).toBe(5);
113112
expect(clip.range[0].frames).toBe(0);
114113
expect(clip.range[1].frames).toBe(15);
115114
// larger than max range
116-
clip.set({ start: <frame>21 });
115+
clip.set({ start: 21 });
117116
expect(clip.start.frames).toBe(20);
118117
expect(clip.offset.frames).toBe(5);
119118
expect(clip.range[0].frames).toBe(15);
@@ -123,28 +122,28 @@ describe('The Media Clip', () => {
123122
});
124123

125124
it('should be adapt the upper slice when setting stop', () => {
126-
clip.duration.frames = <frame>20;
127-
clip.subclip(<frame>5, <frame>15);
128-
clip.set({ offset: <frame>5 });
125+
clip.duration.frames = 20;
126+
clip.subclip(5, 15);
127+
clip.set({ offset: 5 });
129128
expect(clip.duration.frames).toBe(20);
130129
expect(clip.start.frames).toBe(10);
131130
expect(clip.stop.frames).toBe(20);
132131
// case in valid range
133-
clip.set({ stop: <frame>15 });
132+
clip.set({ stop: 15 });
134133
expect(clip.start.frames).toBe(10);
135134
expect(clip.offset.frames).toBe(5);
136135
expect(clip.range[0].frames).toBe(5);
137136
expect(clip.range[1].frames).toBe(10);
138137
// lower than min range
139-
clip.set({ stop: <frame>10 });
138+
clip.set({ stop: 10 });
140139
expect(clip.start.frames).toBe(10);
141140
expect(clip.offset.frames).toBe(5);
142141
expect(clip.range[0].frames).toBe(5);
143142
expect(clip.range[0].millis).toBe(167);
144143
expect(clip.range[1].frames).toBe(5);
145144
expect(clip.range[1].millis).toBe(168);
146145
// larger than max range
147-
clip.set({ stop: <frame>26 });
146+
clip.set({ stop: 26 });
148147
expect(clip.start.frames).toBe(10);
149148
expect(clip.offset.frames).toBe(5);
150149
expect(clip.range[0].frames).toBe(5);
@@ -153,8 +152,8 @@ describe('The Media Clip', () => {
153152

154153
it('should be adaptable to a track', async () => {
155154
// use common multiples of 30 and 15
156-
clip.duration.frames = <frame>60;
157-
clip.set({ offset: <frame>30 }).subclip(<frame>5, <frame>50);
155+
clip.duration.frames = 60;
156+
clip.set({ offset: 30 }).subclip(5, 50);
158157

159158
// 30 fps is the default
160159
const composition = new Composition();
@@ -199,7 +198,7 @@ describe('The Media Clip', () => {
199198
it('should be seekable', async () => {
200199
clip.element = document.createElement('video');
201200
clip.duration.seconds = 20;
202-
clip.subclip(<frame>150, <frame>450);
201+
clip.subclip(150, 450);
203202
// in range
204203
clip.seek(Timestamp.fromFrames(300));
205204
expect(clip.element.currentTime).toBe(10);
@@ -214,8 +213,8 @@ describe('The Media Clip', () => {
214213
it('should be seekable with offset', async () => {
215214
clip.element = document.createElement('video');
216215
clip.duration.seconds = 20;
217-
clip.subclip(<frame>(5 * 30), <frame>(15 * 30));
218-
clip.set({ offset: <frame>(10 * 30) });
216+
clip.subclip(5 * 30, 15 * 30);
217+
clip.set({ offset: 10 * 30 });
219218
expect(clip.start.seconds).toBe(15);
220219
expect(clip.stop.seconds).toBe(25);
221220
// in range
@@ -230,12 +229,12 @@ describe('The Media Clip', () => {
230229
});
231230

232231
it('should offset by a given number', async () => {
233-
clip.duration.frames = <frame>20;
234-
clip.set({ offset: <frame>100, name: 'foo' });
232+
clip.duration.frames = 20;
233+
clip.set({ offset: 100, name: 'foo' });
235234
clip.state = 'READY';
236235

237-
const clip2 = new MediaClip({ offset: <frame>60 });
238-
clip2.duration.frames = <frame>30;
236+
const clip2 = new MediaClip({ offset: 60 });
237+
clip2.duration.frames = 30;
239238
clip2.state = 'READY';
240239

241240
const composition = new Composition();
@@ -246,14 +245,14 @@ describe('The Media Clip', () => {
246245
expect(track.clips.length).toBe(2);
247246
expect(track.clips[1].name).toBe('foo');
248247

249-
clip.offsetBy(<frame>-80);
248+
clip.offsetBy(-80);
250249

251250
expect(track.clips.length).toBe(2);
252251
expect(track.clips[0].name).toBe('foo');
253252
expect(track.clips[0].start.frames).toBe(20);
254253
expect(track.clips[0].stop.frames).toBe(40);
255254

256-
clip.offsetBy(<frame>30);
255+
clip.offsetBy(30);
257256

258257
expect(track.clips.length).toBe(2);
259258
expect(track.clips[0].name).toBe('foo');

src/composition/composition.spec.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { Clip, TextClip } from '../clips';
1111
import { AudioTrack, CaptionTrack, HtmlTrack, ImageTrack, TextTrack, Track, VideoTrack } from '../tracks';
1212
import { Timestamp } from '../models';
1313

14-
import type { frame } from '../types';
15-
1614
describe('The composition', () => {
1715
let composition: Composition;
1816
const frameMock = vi.fn();
@@ -54,21 +52,21 @@ describe('The composition', () => {
5452
});
5553

5654
it('should get the correct duration', async () => {
57-
const clip0 = new Clip().set({ stop: <frame>(12 * 30) });
55+
const clip0 = new Clip({ stop: 12 * 30 });
5856
const track0 = composition.createTrack('base');
5957
await track0.add(clip0);
6058
expect(composition.duration.seconds).toBe(12);
6159
expect(composition.duration.frames).toBe(12 * 30);
6260

63-
const clip1 = new Clip().set({ stop: <frame>(18 * 30) });
61+
const clip1 = new Clip({ stop: 18 * 30 });
6462
const track1 = composition.createTrack('base');
6563
await track1.add(clip1);
6664
expect(composition.duration.seconds).toBe(18);
6765
expect(composition.duration.frames).toBe(18 * 30);
6866
});
6967

7068
it('should set the duration appropriately', async () => {
71-
const clip0 = new Clip().set({ stop: <frame>(12 * 30) });
69+
const clip0 = new Clip({ stop: 12 * 30 });
7270
const track0 = composition.createTrack('base');
7371
await track0.add(clip0);
7472
expect(composition.duration.seconds).toBe(12);
@@ -77,7 +75,7 @@ describe('The composition', () => {
7775
composition.duration = 4;
7876
expect(composition.duration.frames).toBe(4);
7977

80-
composition.duration = Timestamp.fromFrames(<frame>(8 * 30));
78+
composition.duration = Timestamp.fromFrames(8 * 30);
8179
expect(composition.duration.seconds).toBe(8);
8280
expect(composition.duration.frames).toBe(8 * 30);
8381
});
@@ -167,7 +165,7 @@ describe('The composition', () => {
167165
});
168166

169167
it('should render clips when user called play', async () => {
170-
const clip = new Clip().set({ stop: <frame>15 });
168+
const clip = new Clip({ stop: 15 });
171169

172170
const track = composition.createTrack('base');
173171
await track.add(clip);
@@ -196,7 +194,7 @@ describe('The composition', () => {
196194
});
197195

198196
it('should stop rendering when pause gets called', async () => {
199-
const clip = new Clip().set({ stop: <frame>(6 * 30) });
197+
const clip = new Clip({ stop: 6 * 30 });
200198
const track = composition.createTrack('base');
201199
await track.add(clip);
202200

@@ -219,7 +217,7 @@ describe('The composition', () => {
219217
});
220218

221219
it('should stop rendering at the end of the duration', async () => {
222-
const clip = new Clip().set({ stop: <frame>(6 * 30) });
220+
const clip = new Clip({ stop: 6 * 30 });
223221
const track = composition.createTrack('base');
224222
await track.add(clip);
225223
composition.duration = 15;
@@ -238,35 +236,35 @@ describe('The composition', () => {
238236
});
239237

240238
it('should be able to screenshot a frame', async () => {
241-
const clip = new Clip().set({ stop: <frame>(6 * 30) });
239+
const clip = new Clip({ stop: 6 * 30 });
242240
const track = composition.createTrack('base');
243241
await track.add(clip);
244242

245-
composition.frame = <frame>10;
243+
composition.frame = 10;
246244
expect(composition.screenshot()).toBe('data:image/png;base64,00');
247245
expect(composition.screenshot('webp')).toBe('data:image/webp;base64,00');
248246
expect(composition.screenshot('jpeg')).toBe('data:image/jpeg;base64,00');
249247
});
250248

251249
it('should be able to calculate the correct time', async () => {
252-
composition.duration = Timestamp.fromFrames(<frame>(20 * 30));
253-
composition.frame = <frame>(10 * 30);
250+
composition.duration = Timestamp.fromFrames(20 * 30);
251+
composition.frame = 10 * 30;
254252
expect(composition.time()).toBe('00:10 / 00:20');
255253

256-
composition.duration = Timestamp.fromFrames(<frame>(90 * 30));
257-
composition.frame = <frame>(80 * 30);
254+
composition.duration = Timestamp.fromFrames(90 * 30);
255+
composition.frame = 80 * 30;
258256

259257
expect(composition.time()).toBe('01:20 / 01:30');
260258

261259
// test milliseconds
262-
composition.duration = Timestamp.fromFrames(<frame>10);
263-
composition.frame = <frame>1;
260+
composition.duration = Timestamp.fromFrames(10);
261+
composition.frame = 1;
264262

265263
expect(composition.time({ milliseconds: true })).toBe('00:00.033 / 00:00.333');
266264

267265
// test hours
268-
composition.duration = Timestamp.fromFrames(<frame>(2 * 60 * 60 * 30));
269-
composition.frame = <frame>(40 * 60 * 30);
266+
composition.duration = Timestamp.fromFrames(2 * 60 * 60 * 30);
267+
composition.frame = 40 * 60 * 30;
270268

271269
expect(composition.time({ hours: true })).toBe('00:40:00 / 02:00:00');
272270
});

0 commit comments

Comments
 (0)