Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Apr 11, 2022
1 parent 4b440a5 commit 97072bd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
20 changes: 19 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import * as assert from "assert";
import { toModernJulianDate } from "../index.js";
import { getDayOfYear, toModernJulianDate } from "../index.js";
describe("getDayOfYear()", () => {
describe("startAtZero = true", () => {
it("Converts 2022-01-01 to 0", () => {
assert.strictEqual(getDayOfYear(new Date(2022, 1 - 1, 1), true), 0);
});
it("Converts 2022-12-31 to 364", () => {
assert.strictEqual(getDayOfYear(new Date(2022, 12 - 1, 31), true), 364);
});
});
describe("startAtZero = false", () => {
it("Converts 2022-01-01 to 1", () => {
assert.strictEqual(getDayOfYear(new Date(2022, 1 - 1, 1), false), 1);
});
it("Converts 2022-12-31 to 365", () => {
assert.strictEqual(getDayOfYear(new Date(2022, 12 - 1, 31), false), 365);
});
});
});
describe("toModernJulianDate()", () => {
const testCases = [
[new Date(2022, 1 - 1, 1, 23, 59, 59),
Expand Down
25 changes: 24 additions & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
/* eslint-disable unicorn/numeric-separators-style */

import * as assert from "assert";
import { toModernJulianDate } from "../index.js";
import { getDayOfYear, toModernJulianDate } from "../index.js";

describe("getDayOfYear()", () => {

describe("startAtZero = true", () => {
it("Converts 2022-01-01 to 0", () => {
assert.strictEqual(getDayOfYear(new Date(2022, 1 - 1, 1), true), 0);
});

it("Converts 2022-12-31 to 364", () => {
assert.strictEqual(getDayOfYear(new Date(2022, 12 - 1, 31), true), 364);
});
});

describe("startAtZero = false", () => {
it("Converts 2022-01-01 to 1", () => {
assert.strictEqual(getDayOfYear(new Date(2022, 1 - 1, 1), false), 1);
});

it("Converts 2022-12-31 to 365", () => {
assert.strictEqual(getDayOfYear(new Date(2022, 12 - 1, 31), false), 365);
});
});
});

describe("toModernJulianDate()", () => {

Expand Down

0 comments on commit 97072bd

Please sign in to comment.