Skip to content

Commit

Permalink
Merge pull request #41 from sineverba/change-var-to-const
Browse files Browse the repository at this point in the history
Change var to const
  • Loading branch information
sineverba committed Dec 22, 2023
2 parents b5fa1eb + 89addb8 commit 7d5857c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Next version
+ Upgrade dependencies
+ Change `var` to `const` in tests

# 2.1.0
+ Add Cucumber
Expand Down
4 changes: 0 additions & 4 deletions TODO.md

This file was deleted.

26 changes: 13 additions & 13 deletions src/__tests__/dateConvert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,57 @@ import { fromIsoToHuman, fromHumanToIso } from "../index";

describe("#fromIsoToHuman", function () {
it("Should return human date", function () {
var isoDate = "20200908";
const isoDate = "20200908";
/**
* Suppress the error
*/
// @ts-expect-error
var result = fromIsoToHuman(isoDate);
const result = fromIsoToHuman(isoDate);
expect(result).toBe("08/09/2020");
});

it("Should manage hyphen separator", function () {
var isoDateWithHyphen = "2020-01-02";
const isoDateWithHyphen = "2020-01-02";
/**
* Suppress the error
*/
// @ts-expect-error
var result = fromIsoToHuman(isoDateWithHyphen);
const result = fromIsoToHuman(isoDateWithHyphen);
expect(result).toBe("02/01/2020");
});

it("Should manage a longer date", function () {
var longerDate = "2022-03-09T12:31:16.699904";
const longerDate = "2022-03-09T12:31:16.699904";
/**
* Suppress the error
*/
// @ts-expect-error
var result = fromIsoToHuman(longerDate);
const result = fromIsoToHuman(longerDate);
expect(result).toBe("09/03/2022");
});

it("Should manage a custom format", function () {
var isoDate = "19821122";
var format = "YYYY-MM-DD";
var result = fromIsoToHuman(isoDate, format);
const isoDate = "19821122";
const format = "YYYY-MM-DD";
const result = fromIsoToHuman(isoDate, format);
expect(result).toBe("1982-11-22");
});
});

describe("#fromHumanToIso", function () {
it("Should return ISO date", function () {
var humanDate = "31/12/2020";
const humanDate = "31/12/2020";
/**
* Suppress the error
*/
// @ts-expect-error
var result = fromHumanToIso(humanDate);
const result = fromHumanToIso(humanDate);
expect(result).toBe("20201231");
});

it("Should manage a date with hyphen", function () {
var humanDate = "2020-12-31";
var result = fromHumanToIso(humanDate, "YYYY-MM-DD");
const humanDate = "2020-12-31";
const result = fromHumanToIso(humanDate, "YYYY-MM-DD");
expect(result).toBe("20201231");
});
});

0 comments on commit 7d5857c

Please sign in to comment.