@@ -31,8 +31,8 @@ describe("IkVideoComponent", () => {
31
31
32
32
it ( "urlEndpoint passed to component should be used over initialized value" , ( ) => {
33
33
let options : IkVideoComponentOptions = {
34
- path : "def " ,
35
- urlEndpoint : "https://example.com "
34
+ urlEndpoint : "https://example.com " ,
35
+ path : "def "
36
36
} ;
37
37
component . setUrl ( options ) ;
38
38
expect ( component . url ) . toBe ( `https://example.com/def` ) ;
@@ -49,6 +49,7 @@ describe("IkVideoComponent", () => {
49
49
let elRef : ElementRef ;
50
50
comp = new IkVideoComponent ( elRef , iKService ) ;
51
51
let options : IkVideoComponentOptions = {
52
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
52
53
path : "/sample-video.mp4"
53
54
} ;
54
55
comp . setUrl ( options ) ;
@@ -65,6 +66,7 @@ describe("IkVideoComponent", () => {
65
66
it ( "new unsupported transformation parameter is passed then it should come in URL as it is" , ( ) => {
66
67
const transformation = [ { foo : "200" , bar : "200" } ] ;
67
68
let options : IkVideoComponentOptions = {
69
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
68
70
src : "https://abc.com/def" ,
69
71
transformation : transformation
70
72
} ;
@@ -75,6 +77,7 @@ describe("IkVideoComponent", () => {
75
77
it ( "supported transformation parameter is passed then it should come in query parameters after transformation" , ( ) => {
76
78
const transformation = [ { height : "200" , width : "200" } , { rotation : "90" } ] ;
77
79
let options : IkVideoComponentOptions = {
80
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
78
81
src : "https://abc.com/def" ,
79
82
transformation : transformation
80
83
} ;
@@ -85,6 +88,7 @@ describe("IkVideoComponent", () => {
85
88
it ( "if SRC is used to create URL, transformartioPosition should be query" , ( ) => {
86
89
const transformation = [ { height : "200" , width : "200" } , { rotation : "90" } ] ;
87
90
let options : IkVideoComponentOptions = {
91
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
88
92
src : "https://abc.com/def" ,
89
93
transformation : transformation
90
94
} ;
@@ -95,6 +99,7 @@ describe("IkVideoComponent", () => {
95
99
it ( "if SRC is used to create URL, transformationPosition should be query even if anything else is passed" , ( ) => {
96
100
const transformation = [ { height : "200" , width : "200" } , { rotation : "90" } ] ;
97
101
let options : IkVideoComponentOptions = {
102
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
98
103
src : "https://example.com/sample-video.mp4" ,
99
104
transformation : transformation ,
100
105
transformationPosition : "path"
@@ -109,6 +114,7 @@ describe("IkVideoComponent", () => {
109
114
it ( "if PATH is used to create URL, transformartionPosition should be kept as is" , ( ) => {
110
115
const transformation = [ { height : "200" , width : "200" } , { rotation : "90" } ] ;
111
116
let options : IkVideoComponentOptions = {
117
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
112
118
path : "sample-video.mp4" ,
113
119
transformation : transformation ,
114
120
transformationPosition : "query"
@@ -122,6 +128,7 @@ describe("IkVideoComponent", () => {
122
128
123
129
it ( "Parameters passed to queryParameters should be present in URL if src is used" , ( ) => {
124
130
let options : IkVideoComponentOptions = {
131
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
125
132
src : "https://example.com/sample-video.mp4" ,
126
133
queryParameters : { version :5 , name : 'check' }
127
134
} ;
@@ -131,6 +138,7 @@ describe("IkVideoComponent", () => {
131
138
132
139
it ( "Parameters passed to queryParameters should be present in URL if src with existing query is used" , ( ) => {
133
140
let options : IkVideoComponentOptions = {
141
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
134
142
src : "https://example.com/sample-video.mp4?foo=bar&baz=nax" ,
135
143
queryParameters : { version :5 , name : 'check' }
136
144
} ;
@@ -141,6 +149,7 @@ describe("IkVideoComponent", () => {
141
149
142
150
it ( "Parameters passed to queryParameters should be present in URL if path is used" , ( ) => {
143
151
let options : IkVideoComponentOptions = {
152
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
144
153
path : "/default.png" ,
145
154
queryParameters : { version :6 , name : 'bar' }
146
155
} ;
@@ -150,6 +159,7 @@ describe("IkVideoComponent", () => {
150
159
151
160
it ( "setUrl should create correct URL when src is provided" , ( ) => {
152
161
let options : IkVideoComponentOptions = {
162
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
153
163
src : "https://test-absolute-path.com/sample-video.mp4"
154
164
} ;
155
165
component . setUrl ( options ) ;
@@ -158,22 +168,34 @@ describe("IkVideoComponent", () => {
158
168
159
169
it ( "setUrl should create correct URL when path is provided" , ( ) => {
160
170
let options : IkVideoComponentOptions = {
171
+ urlEndpoint : "https://ik.imagekit.io/company/" ,
161
172
path : "def"
162
173
} ;
163
174
component . setUrl ( options ) ;
164
175
expect ( component . url ) . toContain ( `https://ik.imagekit.io/company/def` ) ;
165
176
} ) ;
166
177
178
+ it ( "if urlEndpoint not set, expect errors to be thrown" , ( ) => {
179
+ const transformation = [ { height : "200" , width : "200" } , { rotation : "90" } ] ;
180
+ let options : IkVideoComponentOptions = {
181
+ transformation : transformation ,
182
+ transformationPosition : "query"
183
+ } ;
184
+ expect ( ( ) => component . getConfigObject ( options ) ) . toThrow ( new Error ( 'Missing urlEndpoint initialization!' ) ) ;
185
+ } ) ;
186
+
167
187
it ( "if SRC and PATH not set, expect errors to be thrown" , ( ) => {
168
188
const transformation = [ { height : "200" , width : "200" } , { rotation : "90" } ] ;
169
189
let options : IkVideoComponentOptions = {
190
+ urlEndpoint : 'https://ik.imagekit.io/example' ,
170
191
transformation : transformation ,
171
192
transformationPosition : "query"
172
193
} ;
173
194
expect ( ( ) => component . getConfigObject ( options ) ) . toThrow ( new Error ( 'Missing src / path during initialization!' ) ) ;
174
195
} ) ;
175
196
176
197
it ( "video DOM src should be set initially" , ( ) => {
198
+ component . urlEndpoint = "https://ik.imagekit.io/example" ;
177
199
component . src = "https://ik.imagekit.io/demo/sample-video.mp4" ;
178
200
fixture . detectChanges ( ) ;
179
201
const ikImageElement : HTMLElement = fixture . nativeElement ;
0 commit comments