@flighthq/displayobject 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/bitmap.d.ts +8 -0
  2. package/dist/bitmap.d.ts.map +1 -0
  3. package/dist/bitmap.js +41 -0
  4. package/dist/bitmap.js.map +1 -0
  5. package/dist/displayContainer.d.ts +5 -0
  6. package/dist/displayContainer.d.ts.map +1 -0
  7. package/dist/displayContainer.js +12 -0
  8. package/dist/displayContainer.js.map +1 -0
  9. package/dist/displayObject.d.ts +8 -0
  10. package/dist/displayObject.d.ts.map +1 -0
  11. package/dist/displayObject.js +32 -0
  12. package/dist/displayObject.js.map +1 -0
  13. package/dist/htmlView.d.ts +8 -0
  14. package/dist/htmlView.d.ts.map +1 -0
  15. package/dist/htmlView.js +35 -0
  16. package/dist/htmlView.js.map +1 -0
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +8 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/internal.d.ts +7 -0
  22. package/dist/internal.d.ts.map +1 -0
  23. package/dist/internal.js +2 -0
  24. package/dist/internal.js.map +1 -0
  25. package/dist/renderView.d.ts +8 -0
  26. package/dist/renderView.d.ts.map +1 -0
  27. package/dist/renderView.js +35 -0
  28. package/dist/renderView.js.map +1 -0
  29. package/dist/stage.d.ts +12 -0
  30. package/dist/stage.d.ts.map +1 -0
  31. package/dist/stage.js +59 -0
  32. package/dist/stage.js.map +1 -0
  33. package/dist/video.d.ts +9 -0
  34. package/dist/video.d.ts.map +1 -0
  35. package/dist/video.js +41 -0
  36. package/dist/video.js.map +1 -0
  37. package/package.json +41 -0
  38. package/src/bitmap.test.ts +130 -0
  39. package/src/displayContainer.test.ts +37 -0
  40. package/src/displayObject.test.ts +174 -0
  41. package/src/htmlView.test.ts +111 -0
  42. package/src/renderView.test.ts +104 -0
  43. package/src/stage.test.ts +211 -0
  44. package/src/video.test.ts +112 -0
@@ -0,0 +1,112 @@
1
+ import type { Video } from '@flighthq/types';
2
+ import { VideoKind } from '@flighthq/types';
3
+
4
+ import {
5
+ computeVideoLocalBoundsRectangle,
6
+ createVideo,
7
+ createVideoData,
8
+ createVideoRuntime,
9
+ getVideoRuntime,
10
+ setVideoSmoothing,
11
+ setVideoSource,
12
+ } from './video';
13
+
14
+ describe('computeVideoLocalBoundsRectangle', () => {
15
+ it('does not modify out when source element is null', () => {
16
+ const video = createVideo();
17
+ const out = { x: 0, y: 0, width: 0, height: 0 };
18
+ computeVideoLocalBoundsRectangle(out as never, video as never);
19
+ expect(out.width).toBe(0);
20
+ expect(out.height).toBe(0);
21
+ });
22
+
23
+ it('sets out dimensions from the video element', () => {
24
+ const video = createVideo();
25
+ const el = document.createElement('video');
26
+ Object.defineProperty(el, 'videoWidth', { get: () => 320 });
27
+ Object.defineProperty(el, 'videoHeight', { get: () => 240 });
28
+ video.data.source = { element: el } as never;
29
+ const out = { x: 0, y: 0, width: 0, height: 0 };
30
+ computeVideoLocalBoundsRectangle(out as never, video as never);
31
+ expect(out.width).toBe(320);
32
+ expect(out.height).toBe(240);
33
+ });
34
+ });
35
+
36
+ describe('createVideo', () => {
37
+ let video: Video;
38
+
39
+ beforeEach(() => {
40
+ video = createVideo();
41
+ });
42
+
43
+ it('initializes default values', () => {
44
+ expect(video.data.smoothing).toBe(true);
45
+ expect(video.kind).toStrictEqual(VideoKind);
46
+ });
47
+
48
+ it('allows pre-defined values', () => {
49
+ const base = {
50
+ data: {
51
+ smoothing: false,
52
+ },
53
+ };
54
+ const obj = createVideo(base);
55
+ expect(obj.data.smoothing).toStrictEqual(base.data.smoothing);
56
+ });
57
+
58
+ it('returns a new object for better hidden-class performance', () => {
59
+ const base = {};
60
+ const obj = createVideo(base);
61
+ expect(obj).not.toStrictEqual(base);
62
+ });
63
+ });
64
+
65
+ describe('createVideoData', () => {
66
+ it('returns default values', () => {
67
+ const data = createVideoData();
68
+ expect(data.smoothing).toBe(true);
69
+ });
70
+
71
+ it('allows pre-defined values', () => {
72
+ const data = createVideoData({ smoothing: false });
73
+ expect(data.smoothing).toBe(false);
74
+ });
75
+ });
76
+
77
+ describe('createVideoRuntime', () => {
78
+ it('returns a non-null runtime', () => {
79
+ const runtime = createVideoRuntime();
80
+ expect(runtime).not.toBeNull();
81
+ });
82
+ });
83
+
84
+ describe('getVideoRuntime', () => {
85
+ it('returns the runtime for a Video', () => {
86
+ const video = createVideo();
87
+ const runtime = getVideoRuntime(video);
88
+ expect(runtime).not.toBeNull();
89
+ });
90
+ });
91
+
92
+ describe('setVideoSmoothing', () => {
93
+ it('updates the smoothing field', () => {
94
+ const video = createVideo();
95
+ setVideoSmoothing(video, false);
96
+ expect(video.data.smoothing).toBe(false);
97
+ setVideoSmoothing(video, true);
98
+ expect(video.data.smoothing).toBe(true);
99
+ });
100
+ });
101
+
102
+ describe('setVideoSource', () => {
103
+ it('updates the source field', () => {
104
+ const video = createVideo();
105
+ const el = document.createElement('video');
106
+ const source = { element: el } as never;
107
+ setVideoSource(video, source);
108
+ expect(video.data.source).toBe(source);
109
+ setVideoSource(video, null);
110
+ expect(video.data.source).toBeNull();
111
+ });
112
+ });