Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cronofy-elements

Package Overview
Dependencies
Maintainers
3
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cronofy-elements - npm Package Compare versions

Comparing version 1.25.0 to 1.25.1

build/CronofyElements.v1.25.1.js

2

package.json
{
"name": "cronofy-elements",
"version": "1.25.0",
"version": "1.25.1",
"description": "Fast track scheduling with Cronofy's embeddable UI Elements",

@@ -5,0 +5,0 @@ "main": "build/npm/CronofyElements.js",

@@ -6,2 +6,3 @@ import React, { useContext, useEffect, useState } from "react";

checkIfDaysMatch,
checkIfLimitsMatch,
getAllLabels

@@ -83,4 +84,9 @@ } from "../../helpers/utils.AvailabilityViewer";

const daysMatch = checkIfDaysMatch(pages.days, allLabels);
const limitsMatch = checkIfLimitsMatch(
limits,
allLabels[pages.current - 1].times,
status.tzid
);
if (!daysMatch) {
if (!daysMatch || !limitsMatch) {
// If they've changed we need to recalculate labels, but

@@ -101,3 +107,3 @@ // this is expensive so we don't want to do it unless we

}
}, [pages]);
}, [pages, limits]);

@@ -104,0 +110,0 @@ useEffect(() => {

@@ -813,1 +813,24 @@ import moment from "moment-timezone";

};
export const checkIfLimitsMatch = ({ start, end }, times, tzid = "Etc/UTC") => {
// Get the first start time in `HH:mm` format
const startTime = moment
.tz(times[0].start, "YYYY-MM-DDTHH:mm:00Z", tzid)
.local()
.format("HH:mm");
// Get the last end time in `HH:mm` format
const rawEndTime = moment
.tz(times[times.length - 1].end, "YYYY-MM-DDTHH:mm:00Z", tzid)
.local()
.format("HH:mm");
// Account for limits.end being "24:00"
const endTime = rawEndTime === "00:00" ? "24:00" : rawEndTime;
const startMatches = startTime === start;
const endMatches = endTime === end;
// The limits match the time-labels if *both* start and end match.
return startMatches && endMatches;
};

@@ -1418,3 +1418,81 @@ import * as utils from "../src/js/helpers/utils.AvailabilityViewer";

});
it("detects when limits match", () => {
const limits = { start: "08:00", end: "17:30" };
const times = [
{
start: "2021-01-18T08:00:00Z",
end: "2021-01-18T17:30:00Z"
}
];
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
expect(matchEmpty).toBe(true);
});
it("detects when start limit does not match", () => {
const limits = { start: "00:00", end: "17:30" };
const times = [
{
start: "2021-01-18T08:00:00Z",
end: "2021-01-18T17:30:00Z"
}
];
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
expect(matchEmpty).toBe(false);
});
it("detects when end limit does not match", () => {
const limits = { start: "08:00", end: "17:00" };
const times = [
{
start: "2021-01-18T08:00:00Z",
end: "2021-01-18T17:30:00Z"
}
];
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
expect(matchEmpty).toBe(false);
});
it("detects when both limits do not match", () => {
const limits = { start: "07:00", end: "17:00" };
const times = [
{
start: "2021-01-18T08:00:00Z",
end: "2021-01-18T17:30:00Z"
}
];
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
expect(matchEmpty).toBe(false);
});
it("detects when both limits do not match", () => {
const limits = { start: "07:00", end: "17:00" };
const times = [
{
start: "2021-01-18T08:00:00Z",
end: "2021-01-18T17:30:00Z"
}
];
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
expect(matchEmpty).toBe(false);
});
it("handles matching limits when end is midnight", () => {
const limits = { start: "08:00", end: "24:00" };
const times = [
{
start: "2021-01-18T08:00:00Z",
end: "2021-01-19T00:00:00Z"
}
];
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
expect(matchEmpty).toBe(true);
});
});
});

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc