@eliasrrosa/tutorhub-public-assets 0.0.9 → 0.0.10

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.
@@ -10,7 +10,6 @@ import { ITime } from "./Time";
10
10
  export declare class ISO8601Time implements ITime {
11
11
  readonly value: string;
12
12
  readonly validator: IISO8601TimeValidator;
13
- readonly timezone?: string;
14
13
  /**
15
14
  * Throws if format is invalid.
16
15
  * Accepted formats: HH:MM:SS and HH:MM.
@@ -6,5 +6,4 @@ export interface ITime {
6
6
  getMinutes: () => string;
7
7
  getSeconds: () => string;
8
8
  getNow: () => string;
9
- readonly timezone?: string;
10
9
  }
@@ -1,4 +1,5 @@
1
+ import { ITime } from "./Time";
1
2
  export interface ITimeSlot {
2
- startTime: string;
3
- endTime: string;
3
+ startTime: ITime;
4
+ endTime: ITime;
4
5
  }
@@ -3,6 +3,7 @@ import { ICourse } from "./Course";
3
3
  import { IRescheduleRequest } from "./RescheduleRequest";
4
4
  import { IDateTimeSlot } from "./DateTimeSlot";
5
5
  import { IDate } from "./Date";
6
+ import { ITime } from "./Time";
6
7
  export interface IUserUnavailableTime {
7
8
  id: string;
8
9
  userId: string;
@@ -10,8 +11,8 @@ export interface IUserUnavailableTime {
10
11
  groupId: string;
11
12
  date: IDate;
12
13
  dayOfTheWeek: number;
13
- startTime: string;
14
- endTime: string;
14
+ startTime: ITime;
15
+ endTime: ITime;
15
16
  isAvailableTime: boolean;
16
17
  course?: ICourse;
17
18
  courseId: string | null;
@@ -24,8 +25,8 @@ export declare class UserUnavailableTime implements IUserUnavailableTime {
24
25
  user?: IUserAuth;
25
26
  groupId: string;
26
27
  date: IDate;
27
- startTime: string;
28
- endTime: string;
28
+ startTime: ITime;
29
+ endTime: ITime;
29
30
  isAvailableTime: boolean;
30
31
  dayOfTheWeek: number;
31
32
  course?: ICourse;
@@ -37,8 +38,8 @@ export declare class UserUnavailableTime implements IUserUnavailableTime {
37
38
  user?: IUserAuth;
38
39
  groupId: string;
39
40
  date: IDate;
40
- startTime: string;
41
- endTime: string;
41
+ startTime: ITime | string;
42
+ endTime: ITime | string;
42
43
  isAvailableTime: boolean;
43
44
  course?: ICourse;
44
45
  courseId: string | null;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserUnavailableTime = void 0;
4
+ const ISO8601Time_1 = require("./ISO8601Time");
4
5
  class UserUnavailableTime {
5
6
  constructor(opts) {
6
7
  this.getDateTimeSlot = () => {
@@ -18,8 +19,8 @@ class UserUnavailableTime {
18
19
  this.groupId = opts.groupId;
19
20
  this.date = opts.date;
20
21
  this.dayOfTheWeek = this.getDayOfTheWeek();
21
- this.startTime = opts.startTime;
22
- this.endTime = opts.endTime;
22
+ this.startTime = typeof opts.startTime == "string" ? new ISO8601Time_1.ISO8601Time(opts.startTime) : opts.startTime;
23
+ this.endTime = typeof opts.endTime == "string" ? new ISO8601Time_1.ISO8601Time(opts.endTime) : opts.endTime;
23
24
  this.isAvailableTime = opts.isAvailableTime;
24
25
  this.course = opts.course;
25
26
  this.courseId = opts.courseId;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ISO8601Date_1 = require("./ISO8601Date");
4
+ const ISO8601Time_1 = require("./ISO8601Time");
4
5
  const UserUnavailableTime_1 = require("./UserUnavailableTime");
5
6
  describe("UserUnavailableTime", () => {
6
- const availableTime = new UserUnavailableTime_1.UserUnavailableTime({
7
+ const availableTimeData = {
7
8
  courseId: "courseId",
8
9
  date: new ISO8601Date_1.ISO8601Date("2025-01-01"),
9
10
  endTime: "15:00",
@@ -12,11 +13,32 @@ describe("UserUnavailableTime", () => {
12
13
  id: "id",
13
14
  isAvailableTime: true,
14
15
  userId: "userId",
16
+ };
17
+ describe("UserUnavailableTime constructor()", () => {
18
+ it("Should be instantiable.", () => {
19
+ const availableTime = new UserUnavailableTime_1.UserUnavailableTime(availableTimeData);
20
+ expect(availableTime).toBeDefined();
21
+ });
22
+ it("Should contain the proper dayOfTheWeek.", () => {
23
+ const availableTime = new UserUnavailableTime_1.UserUnavailableTime(availableTimeData);
24
+ expect(availableTime.dayOfTheWeek).toBe(3);
25
+ });
26
+ it("Should instantiate ISO8601Time for startTime and endTime", () => {
27
+ const availableTime = new UserUnavailableTime_1.UserUnavailableTime(availableTimeData);
28
+ expect(availableTime.startTime).toBeInstanceOf(ISO8601Time_1.ISO8601Time);
29
+ expect(availableTime.endTime).toBeInstanceOf(ISO8601Time_1.ISO8601Time);
30
+ });
31
+ it("Should throw given invalid startTime or endTime format", () => {
32
+ const availableTime = () => new UserUnavailableTime_1.UserUnavailableTime(Object.assign(Object.assign({}, availableTimeData), { startTime: "25:00:00" }));
33
+ expect(availableTime).toThrow();
34
+ });
15
35
  });
16
- it("Should be instantiable.", () => {
17
- expect(availableTime).toBeDefined();
18
- });
19
- it("Should contain the proper dayOfTheWeek.", () => {
20
- expect(availableTime.dayOfTheWeek).toBe(3);
36
+ describe("UserUnavailableTime.getDateTimeSlot()", () => {
37
+ const availableTime = new UserUnavailableTime_1.UserUnavailableTime(Object.assign({}, availableTimeData));
38
+ it("Should return an object of type IDateTimeSlot", () => {
39
+ expect(availableTime.getDateTimeSlot().date).toBeInstanceOf(ISO8601Date_1.ISO8601Date);
40
+ expect(availableTime.getDateTimeSlot().timeSlot.endTime).toBeInstanceOf(ISO8601Time_1.ISO8601Time);
41
+ expect(availableTime.getDateTimeSlot().timeSlot.startTime).toBeInstanceOf(ISO8601Time_1.ISO8601Time);
42
+ });
21
43
  });
22
44
  });
package/dist/index.cjs CHANGED
@@ -333,8 +333,8 @@ var UserUnavailableTime = class {
333
333
  this.groupId = opts.groupId;
334
334
  this.date = opts.date;
335
335
  this.dayOfTheWeek = this.getDayOfTheWeek();
336
- this.startTime = opts.startTime;
337
- this.endTime = opts.endTime;
336
+ this.startTime = typeof opts.startTime == "string" ? new ISO8601Time(opts.startTime) : opts.startTime;
337
+ this.endTime = typeof opts.endTime == "string" ? new ISO8601Time(opts.endTime) : opts.endTime;
338
338
  this.isAvailableTime = opts.isAvailableTime;
339
339
  this.course = opts.course;
340
340
  this.courseId = opts.courseId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliasrrosa/tutorhub-public-assets",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Assets, mainly interfaces, to be shared among different Tutorhub apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",