Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F995435
time-units.test.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
time-units.test.ts
View Options
import
time_units
,
{
TimeUnit
}
from
"./time-units"
;
import
*
as
assert
from
"assert"
;
const
formats
:
{
[
full_name
:
string
]
:
[
TimeUnit
,
number
]
}
=
{
hours
:
[
"h"
,
3600000
],
minutes
:
[
"m"
,
60000
],
seconds
:
[
"s"
,
1000
],
miliseconds
:
[
"ms"
,
1
],
};
describe
(
"time-units-function"
,
()
=>
{
describe
(
"convertion"
,
()
=>
{
Object
.
keys
(
formats
).
forEach
((
format
:
keyof
typeof
formats
)
=>
{
it
(
`should convert
${
format
}
to hours`
,
()
=>
{
const
result
=
time_units
(
formats
[
format
][
0
],
"h"
,
1
);
assert
.
equal
(
result
,
(
formats
[
format
][
1
]
/
3600000
).
toPrecision
(
8
)
);
});
it
(
`should convert
${
format
}
to minutes`
,
()
=>
{
const
result
=
time_units
(
formats
[
format
][
0
],
"m"
,
1
);
assert
.
equal
(
result
,
(
formats
[
format
][
1
]
/
60000
).
toPrecision
(
8
)
);
});
it
(
`should convert
${
format
}
to seconds`
,
()
=>
{
const
result
=
time_units
(
formats
[
format
][
0
],
"s"
,
1
);
assert
.
equal
(
result
,
(
formats
[
format
][
1
]
/
1000
).
toPrecision
(
8
)
);
});
it
(
`should convert
${
format
}
to miliseconds`
,
()
=>
{
const
result
=
time_units
(
formats
[
format
][
0
],
"ms"
,
1
);
assert
.
equal
(
result
,
(
formats
[
format
][
1
]
/
1
).
toPrecision
(
8
));
});
});
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Mon, Dec 23, 04:28 (12 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
555873
Default Alt Text
time-units.test.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment