@twasik4/pocket-service 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /// <reference types="vitest/globals" />
2
2
  import { Service } from "../src/workers/service";
3
3
 
4
- describe.only("Redis Dependency", () => {
4
+ describe("Redis Dependency", () => {
5
5
  let service: Service<{}>;
6
6
 
7
7
  beforeAll(async () => {
@@ -0,0 +1,30 @@
1
+ /// <reference types="vitest/globals" />
2
+ import {
3
+ generateRandomHexString,
4
+ getUseableDatesFromMs,
5
+ } from "../src/workers/utils";
6
+
7
+ describe("Utils", () => {
8
+ it("generates a hex string of the requested length", () => {
9
+ const value = generateRandomHexString(16);
10
+ expect(value).toHaveLength(16);
11
+ expect(value).toMatch(/^[0-9a-f]+$/);
12
+ });
13
+
14
+ it("throws when requested length is odd", () => {
15
+ expect(() => generateRandomHexString(3)).toThrow(
16
+ "Length must be an even number",
17
+ );
18
+ });
19
+
20
+ it("converts milliseconds to day/hour/minute/second parts", () => {
21
+ const ms =
22
+ 2 * 24 * 60 * 60 * 1000 + 3 * 60 * 60 * 1000 + 4 * 60 * 1000 + 5 * 1000;
23
+ expect(getUseableDatesFromMs(ms)).toEqual({
24
+ days: 2,
25
+ hours: 3,
26
+ minutes: 4,
27
+ seconds: 5,
28
+ });
29
+ });
30
+ });