@@ -2,6 +2,7 @@ const { expect } = require('chai')
22const sinon = require ( 'sinon' )
33const { doInitFilter, doFilter } = require ( '../src/pytest_html/scripts/filter.js' )
44const { doInitSort, doSort } = require ( '../src/pytest_html/scripts/sort.js' )
5+ const { formatDuration } = require ( '../src/pytest_html/scripts/utils.js' )
56const dataModule = require ( '../src/pytest_html/scripts/datamanager.js' )
67const storageModule = require ( '../src/pytest_html/scripts/storage.js' )
78
@@ -92,7 +93,7 @@ describe('Sort tests', () => {
9293 let sortDirectionMock
9394 beforeEach ( ( ) => dataModule . manager . resetRender ( ) )
9495
95- afterEach ( ( ) => [ sortMock , sortDirectionMock , managerSpy ] . forEach ( ( fn ) => fn . restore ( ) ) )
96+ afterEach ( ( ) => [ sortMock , sortDirectionMock , managerSpy ] . forEach ( ( fn ) => fn . restore ( ) ) )
9697 it ( 'has no stored sort' , ( ) => {
9798 sortMock = sinon . stub ( storageModule , 'getSort' ) . returns ( null )
9899 sortDirectionMock = sinon . stub ( storageModule , 'getSortDirection' ) . returns ( null )
@@ -141,3 +142,17 @@ describe('Sort tests', () => {
141142 } )
142143 } )
143144} )
145+
146+ describe ( 'utils tests' , ( ) => {
147+ describe ( 'formatDuration' , ( ) => {
148+ it ( 'handles small durations' , ( ) => {
149+ expect ( formatDuration ( 123 ) ) . to . eql ( '123ms' )
150+ expect ( formatDuration ( 0 ) ) . to . eql ( '0ms' )
151+ expect ( formatDuration ( 999 ) ) . to . eql ( '999ms' )
152+ } )
153+ it ( 'handles larger durations' , ( ) => {
154+ expect ( formatDuration ( 1234 ) ) . to . eql ( '00:00:01' )
155+ expect ( formatDuration ( 12345678 ) ) . to . eql ( '03:25:46' )
156+ } )
157+ } )
158+ } )
0 commit comments