@@ -8,57 +8,66 @@ type LogEntry = { level: string; tag: string; message: string };
88
99describe ( 'RiveLog' , ( ) => {
1010 // Deprecation warnings only fire in the experimental backend
11- ( isExperimental ? it : it . skip ) ( 'captures deprecation warning from sync method' , async ( ) => {
12- const logs : LogEntry [ ] = [ ] ;
13- RiveLog . setHandler ( ( level , tag , message ) => {
14- logs . push ( { level, tag, message } ) ;
15- } ) ;
16-
17- const file = await RiveFileFactory . fromSource ( BOUNCING_BALL , undefined ) ;
18-
19- file . defaultArtboardViewModel ( ) ;
20-
21- await waitFor (
22- ( ) => {
23- const deprecation = logs . find ( ( l ) => l . tag === 'Deprecation' ) ;
24- expect ( deprecation ) . toBeDefined ( ) ;
25- expect ( deprecation ! . level ) . toBe ( 'warn' ) ;
26- expect ( deprecation ! . message ) . toContain ( 'defaultArtboardViewModel' ) ;
27- expect ( deprecation ! . message ) . toContain ( 'defaultArtboardViewModelAsync' ) ;
28- } ,
29- { timeout : 2000 }
30- ) ;
31-
32- RiveLog . resetHandler ( ) ;
33- cleanup ( ) ;
34- } ) ;
35-
36- ( isExperimental ? it : it . skip ) ( 'emits each deprecation only once' , async ( ) => {
37- const logs : LogEntry [ ] = [ ] ;
38- RiveLog . setHandler ( ( level , tag , message ) => {
39- logs . push ( { level, tag, message } ) ;
40- } ) ;
41-
42- const file = await RiveFileFactory . fromSource ( BOUNCING_BALL , undefined ) ;
43-
44- // Use artboardNames — a different deprecated method so the once-per-session
45- // dedup doesn't collide with the previous test.
46- file . artboardNames ;
47- file . artboardNames ;
48-
49- await waitFor (
50- ( ) => {
51- const deprecations = logs . filter (
52- ( l ) => l . tag === 'Deprecation' && l . message . includes ( 'artboardNames' )
53- ) ;
54- expect ( deprecations . length ) . toBe ( 1 ) ;
55- } ,
56- { timeout : 2000 }
57- ) ;
58-
59- RiveLog . resetHandler ( ) ;
60- cleanup ( ) ;
61- } ) ;
11+ ( isExperimental ? it : it . skip ) (
12+ 'captures deprecation warning from sync method' ,
13+ async ( ) => {
14+ const logs : LogEntry [ ] = [ ] ;
15+ RiveLog . setHandler ( ( level , tag , message ) => {
16+ logs . push ( { level, tag, message } ) ;
17+ } ) ;
18+
19+ const file = await RiveFileFactory . fromSource ( BOUNCING_BALL , undefined ) ;
20+
21+ file . defaultArtboardViewModel ( ) ;
22+
23+ await waitFor (
24+ ( ) => {
25+ const deprecation = logs . find ( ( l ) => l . tag === 'Deprecation' ) ;
26+ expect ( deprecation ) . toBeDefined ( ) ;
27+ expect ( deprecation ! . level ) . toBe ( 'warn' ) ;
28+ expect ( deprecation ! . message ) . toContain ( 'defaultArtboardViewModel' ) ;
29+ expect ( deprecation ! . message ) . toContain (
30+ 'defaultArtboardViewModelAsync'
31+ ) ;
32+ } ,
33+ { timeout : 2000 }
34+ ) ;
35+
36+ RiveLog . resetHandler ( ) ;
37+ cleanup ( ) ;
38+ }
39+ ) ;
40+
41+ ( isExperimental ? it : it . skip ) (
42+ 'emits each deprecation only once' ,
43+ async ( ) => {
44+ const logs : LogEntry [ ] = [ ] ;
45+ RiveLog . setHandler ( ( level , tag , message ) => {
46+ logs . push ( { level, tag, message } ) ;
47+ } ) ;
48+
49+ const file = await RiveFileFactory . fromSource ( BOUNCING_BALL , undefined ) ;
50+
51+ // Use artboardNames — a different deprecated method so the once-per-session
52+ // dedup doesn't collide with the previous test.
53+ file . artboardNames ;
54+ file . artboardNames ;
55+
56+ await waitFor (
57+ ( ) => {
58+ const deprecations = logs . filter (
59+ ( l ) =>
60+ l . tag === 'Deprecation' && l . message . includes ( 'artboardNames' )
61+ ) ;
62+ expect ( deprecations . length ) . toBe ( 1 ) ;
63+ } ,
64+ { timeout : 2000 }
65+ ) ;
66+
67+ RiveLog . resetHandler ( ) ;
68+ cleanup ( ) ;
69+ }
70+ ) ;
6271
6372 it ( 'suppresses all logs with a no-op handler' , async ( ) => {
6473 const logs : LogEntry [ ] = [ ] ;
0 commit comments