Skip to content

Commit

Permalink
Add a default, empty config object for DateTime, Duration, and Interv…
Browse files Browse the repository at this point in the history
…al constructors
  • Loading branch information
mbStavola committed Jun 28, 2024
1 parent cea7b5f commit dfbd8d9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ export default class DateTime {
/**
* @access private
*/
constructor(config) {
constructor(config = {}) {
const zone = config.zone || Settings.defaultZone;

let invalid =
Expand Down
2 changes: 1 addition & 1 deletion src/duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export default class Duration {
/**
* @private
*/
constructor(config) {
constructor(config = {}) {
const accurate = config.conversionAccuracy === "longterm" || false;
let matrix = accurate ? accurateMatrix : casualMatrix;

Expand Down
2 changes: 1 addition & 1 deletion src/interval.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class Interval {
/**
* @private
*/
constructor(config) {
constructor(config = {}) {
/**
* @access private
*/
Expand Down
7 changes: 7 additions & 0 deletions test/datetime/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const withDefaultLocale = Helpers.withDefaultLocale,
withthrowOnInvalid = Helpers.setUnset("throwOnInvalid"),
withDefaultZone = Helpers.withDefaultZone;

//------
// new
//------
test("Default constructor works", () => {
expect(() => new DateTime()).not.toThrow();
});

//------
// .now()
//------
Expand Down
7 changes: 7 additions & 0 deletions test/duration/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

import { Duration } from "../../src/luxon";

//------
// new
//------
test("Default constructor works", () => {
expect(() => new Duration()).not.toThrow();
});

//------
// .fromObject()
//-------
Expand Down
7 changes: 7 additions & 0 deletions test/interval/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import Helpers from "../helpers";

const withThrowOnInvalid = Helpers.setUnset("throwOnInvalid");

//------
// new
//------
test("Default constructor works", () => {
expect(() => new Interval()).not.toThrow();
});

//------
// .fromObject()
//-------
Expand Down

0 comments on commit dfbd8d9

Please sign in to comment.