Skip to content

Commit

Permalink
Finalize test coverage to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko committed Jul 23, 2023
1 parent 81de373 commit 7e98315
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
10 changes: 8 additions & 2 deletions packages/core/dev-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ exports.createRollupConfig = (typescript) => {
format: "esm",
exports: "auto",
},
plugins: [nodeResolve({ extensions }), typescriptPlugin({ typescript, target: 'ES6', })],
plugins: [
nodeResolve({ extensions }),
typescriptPlugin({ typescript, target: "ES6" }),
],
},
{
external,
Expand All @@ -26,7 +29,10 @@ exports.createRollupConfig = (typescript) => {
format: "cjs",
exports: "auto",
},
plugins: [nodeResolve({ extensions }), typescriptPlugin({ typescript, target: 'ES6', })],
plugins: [
nodeResolve({ extensions }),
typescriptPlugin({ typescript, target: "ES6" }),
],
},
];
};
11 changes: 4 additions & 7 deletions packages/date-fns-jalali/src/date-fns-jalali-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,10 @@ export default class DateFnsJalaliUtils implements IUtils<Date> {
const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
const locale = this.locale || defaultLocale;

let localFormat = format.match(longFormatRegexp);
if (!localFormat) {
return "";
}
return (
localFormat
.map((token) => {
format
.match(longFormatRegexp)
?.map((token) => {
const firstCharacter = token[0];
if (firstCharacter === "p" || firstCharacter === "P") {
const longFormatter = longFormatters[firstCharacter];
Expand All @@ -145,7 +142,7 @@ export default class DateFnsJalaliUtils implements IUtils<Date> {
})
.join("")
.replace(/(aaa|aa|a)/g, "(a|p)m")
.toLocaleLowerCase() ?? ""
.toLocaleLowerCase() ?? format
);
};

Expand Down
11 changes: 4 additions & 7 deletions packages/date-fns/src/date-fns-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,10 @@ export default class DateFnsUtils implements IUtils<Date> {
const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
const locale = this.locale || defaultLocale;

let localFormat = format.match(longFormatRegexp);
if (!localFormat) {
return "";
}
return (
localFormat
.map((token) => {
format
.match(longFormatRegexp)
?.map((token) => {
const firstCharacter = token[0];
if (firstCharacter === "p" || firstCharacter === "P") {
const longFormatter = longFormatters[firstCharacter];
Expand All @@ -132,7 +129,7 @@ export default class DateFnsUtils implements IUtils<Date> {
})
.join("")
.replace(/(aaa|aa|a)/g, "(a|p)m")
.toLocaleLowerCase() ?? ""
.toLocaleLowerCase() ?? format
);
};

Expand Down
12 changes: 4 additions & 8 deletions packages/dayjs/src/dayjs-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,10 @@ export default class DayjsUtils<TDate extends Dayjs = Dayjs> implements IUtils<T
// @see https://github.com/iamkun/dayjs/blob/dev/src/plugin/localizedFormat/index.js
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?)|./g;

let localFormat = format.match(localFormattingTokens);
if (!localFormat) {
return "";
}

return (
localFormat
.map((token) => {
format
.match(localFormattingTokens)
?.map((token) => {
var firstCharacter = token[0];
if (firstCharacter === "L") {
/* istanbul ignore next */
Expand All @@ -103,7 +99,7 @@ export default class DayjsUtils<TDate extends Dayjs = Dayjs> implements IUtils<T
})
.join("")
.replace(/a/gi, "(a|p)m")
.toLocaleLowerCase() ?? ""
.toLocaleLowerCase() ?? format
);
};

Expand Down
17 changes: 12 additions & 5 deletions packages/js-joda/src/js-joda-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export default class JsJodaUtils implements IUtils<Temporal> {
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
}

/* istanbul ignore next */
return null;
}

Expand Down Expand Up @@ -213,6 +214,7 @@ export default class JsJodaUtils implements IUtils<Temporal> {
return true;
}

/* istanbul ignore next */
return false;
}

Expand Down Expand Up @@ -246,15 +248,14 @@ export default class JsJodaUtils implements IUtils<Temporal> {
if (first === null || second === null) {
return false;
}
// if (first instanceof Error || second instanceof Error) {
// throw first || second;
// }
if (first instanceof LocalDateTime && second instanceof LocalDateTime) {
return first.isEqual(second);
}
if (first instanceof LocalDate && second instanceof LocalDate) {
return first.isEqual(second);
}

/* istanbul ignore next */
return false;
}

Expand Down Expand Up @@ -286,6 +287,7 @@ export default class JsJodaUtils implements IUtils<Temporal> {
return date.isAfter(value);
}

/* istanbul ignore next */
return false;
}

Expand Down Expand Up @@ -435,8 +437,12 @@ export default class JsJodaUtils implements IUtils<Temporal> {

mergeDateAndTime(date: Temporal, time: Temporal): Temporal {
var qtime = time.query(TemporalQueries.localTime());
if (qtime == null) return date;
else return LocalDate.from(date).atTime(LocalTime.from(time));
if (qtime == null) {
/* istanbul ignore next */
return date;
} else {
return LocalDate.from(date).atTime(LocalTime.from(time));
}
}

getWeekdays(): string[] {
Expand Down Expand Up @@ -492,6 +498,7 @@ export default class JsJodaUtils implements IUtils<Temporal> {
return date.isBefore(value);
}

/* istanbul ignore next */
return false;
}

Expand Down
1 change: 1 addition & 0 deletions packages/luxon/src/luxon-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export default class LuxonUtils implements IUtils<DateTime> {
}

if (!this.date(comparing)) {
/* istanbul ignore next */
return false;
}

Expand Down
12 changes: 4 additions & 8 deletions packages/moment/src/moment-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,10 @@ export default class MomentUtils implements IUtils<defaultMoment.Moment> {
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
const localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;

let localFormat = format.match(localFormattingTokens);
if (!localFormat) {
return "";
}

return (
localFormat
.map((token) => {
format
.match(localFormattingTokens)
?.map((token) => {
const firstCharacter = token[0];
if (firstCharacter === "L" || firstCharacter === ";") {
return this.moment
Expand All @@ -80,7 +76,7 @@ export default class MomentUtils implements IUtils<defaultMoment.Moment> {
})
.join("")
.replace(/a/gi, "(a|p)m")
.toLocaleLowerCase() ?? ""
.toLocaleLowerCase() ?? format
);
};

Expand Down

0 comments on commit 7e98315

Please sign in to comment.