11import Tracelib from '../src/index'
22import JANK_TRACE_LOG from './__fixtures__/jankTraceLog.json'
33
4+ let trace : Tracelib
5+ beforeAll ( ( ) => {
6+ trace = new Tracelib ( JANK_TRACE_LOG )
7+ } )
8+
49test ( 'should contain traceLog' , ( ) => {
510 const sampleTrace = new Tracelib ( { foo : 'bar' } )
611 expect ( sampleTrace . tracelog ) . toEqual ( { foo : 'bar' } )
712} )
813
914test ( 'should get FPS' , ( ) => {
10- const trace = new Tracelib ( JANK_TRACE_LOG )
1115 const result = trace . getFPS ( )
1216 expect ( result ) . toMatchSnapshot ( )
1317} )
1418
15- test ( 'getSummary: should get summary data ' , ( ) => {
16- const trace = new Tracelib ( JANK_TRACE_LOG )
17- const result = trace . getSummary ( )
18- expect ( result ) . toMatchSnapshot ( )
19- } )
19+ describe ( 'getSummary' , ( ) => {
20+ it ( 'should get summary data' , ( ) => {
21+ const result = trace . getSummary ( )
22+ expect ( result ) . toMatchSnapshot ( )
23+ } )
2024
21- test ( 'getSummary: should throw error if main track is missing' , ( ) => {
22- const trace = new Tracelib ( [ ] )
23- expect ( ( ) => trace . getSummary ( ) )
24- . toThrow ( new Error ( 'MainTrack is missing in traceLog' ) )
25- } )
25+ it ( 'should not throw error on second call of getSummary' , ( ) => {
26+ const result = trace . getSummary ( )
27+ expect ( result ) . toMatchSnapshot ( )
28+ } )
2629
27- test ( 'should get summary data between passed range ' , ( ) => {
28- const trace = new Tracelib ( JANK_TRACE_LOG )
29- const result = trace . getSummary ( 289960055.634 , 289960729.717 )
30- expect ( result ) . toMatchSnapshot ( )
31- } )
30+ it ( 'should throw error if main track is missing ' , ( ) => {
31+ const tracelib = new Tracelib ( [ ] )
32+ expect ( ( ) => tracelib . getSummary ( ) )
33+ . toThrow ( new Error ( 'MainTrack is missing in traceLog' ) )
34+ } )
3235
33- test ( 'getWarningCounts: should get warning counts ', ( ) => {
34- const trace = new Tracelib ( JANK_TRACE_LOG )
35- const result = trace . getWarningCounts ( )
36- expect ( result ) . toMatchSnapshot ( )
36+ it ( ' should get summary data between passed range ', ( ) => {
37+ const result = trace . getSummary ( 289960055.634 , 289960729.717 )
38+ expect ( result ) . toMatchSnapshot ( )
39+ } )
3740} )
3841
39- test ( 'getWarningCounts: should throw error if main track is missing' , ( ) => {
40- const trace = new Tracelib ( [ ] )
41- expect ( ( ) => trace . getWarningCounts ( ) )
42- . toThrow ( new Error ( 'MainTrack is missing in traceLog' ) )
42+ describe ( 'getWarningCounts' , ( ) => {
43+ it ( 'should get warning counts' , ( ) => {
44+ const result = trace . getWarningCounts ( )
45+ expect ( result ) . toMatchSnapshot ( )
46+ } )
47+
48+ it ( 'should throw error if main track is missing' , ( ) => {
49+ const tracelib = new Tracelib ( [ ] )
50+ expect ( ( ) => tracelib . getWarningCounts ( ) )
51+ . toThrow ( new Error ( 'MainTrack is missing in traceLog' ) )
52+ } )
4353} )
4454
4555test ( 'should get memory counters' , ( ) => {
46- const trace = new Tracelib ( JANK_TRACE_LOG )
4756 const result = trace . getMemoryCounters ( )
4857 expect ( result ) . toMatchSnapshot ( )
4958} )
5059
51- test ( 'mainTrackEvents: should get events ' , ( ) => {
52- const trace = new Tracelib ( JANK_TRACE_LOG )
53- const result = trace . getMainTrackEvents ( )
54- expect ( result . length ) . toEqual ( 56244 )
55- } )
60+ describe ( 'mainTrackEvents' , ( ) => {
61+ it ( 'should get events' , ( ) => {
62+ const result = trace . getMainTrackEvents ( )
63+ expect ( result . length ) . toEqual ( 56244 )
64+ } )
5665
57- test ( 'mainTrackEvents: should throws error if main track is missing' , ( ) => {
58- const trace = new Tracelib ( [ ] )
59- expect ( ( ) => trace . getMainTrackEvents ( ) )
60- . toThrow ( new Error ( 'MainTrack is missing in traceLog' ) )
61- } )
66+ it ( 'should throws error if main track is missing' , ( ) => {
67+ const tracelib = new Tracelib ( [ ] )
68+ expect ( ( ) => tracelib . getMainTrackEvents ( ) )
69+ . toThrow ( new Error ( 'MainTrack is missing in traceLog' ) )
70+ } )
71+ } )
0 commit comments