@@ -16,3 +16,31 @@ describe("Runtime exposes", function () {
1616 expect ( Math . abs ( dateDelta - timeDelta ) ) . toBeLessThan ( dateDelta * 0.25 ) ;
1717 } ) ;
1818} ) ;
19+
20+ describe ( "Performance object" , ( ) => {
21+ it ( "should be available" , ( ) => {
22+ expect ( performance ) . toBeDefined ( ) ;
23+ } ) ;
24+ it ( "should have a now function" , ( ) => {
25+ expect ( performance . now ) . toBeDefined ( ) ;
26+ } ) ;
27+ it ( "should have a now function that returns a number" , ( ) => {
28+ expect ( typeof performance . now ( ) ) . toBe ( "number" ) ;
29+ } ) ;
30+ it ( "should have timeOrigin" , ( ) => {
31+ expect ( performance . timeOrigin ) . toBeDefined ( ) ;
32+ } ) ;
33+ it ( "should have timeOrigin that is a number" , ( ) => {
34+ expect ( typeof performance . timeOrigin ) . toBe ( "number" ) ;
35+ } ) ;
36+ it ( "should have timeOrigin that is greater than 0" , ( ) => {
37+ expect ( performance . timeOrigin ) . toBeGreaterThan ( 0 ) ;
38+ } ) ;
39+ it ( "should be close to the current time" , ( ) => {
40+ const dateNow = Date . now ( ) ;
41+ const performanceNow = performance . now ( ) ;
42+ const timeOrigin = performance . timeOrigin ;
43+ const performanceAccurateNow = timeOrigin + performanceNow ;
44+ expect ( Math . abs ( dateNow - performanceAccurateNow ) ) . toBeLessThan ( 10 ) ;
45+ } ) ;
46+ } ) ;
0 commit comments