Skip to content

Commit

Permalink
test: fix toDateString -> timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
Garrison authored and Garrison committed Oct 31, 2023
1 parent 6337794 commit ee9065d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/to-date-string.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { describe, expect, it } from 'vitest';
import { toDateString, toISODateString } from '../src';

const TIMEZONE = new Date().getTimezoneOffset() * 60 * 1000;

const NUMBER_POSITIVE = 946684800000 + TIMEZONE;
const NUMBER_NEGATIVE = -3155671817000 + TIMEZONE;

describe('toDateString', () => {
/**
* Positive testing
Expand All @@ -9,12 +14,12 @@ describe('toDateString', () => {
expect(toDateString(0)).toBe('01.01.1970');
});

it('positive -> input positive number', () => {
expect(toDateString(-3155682617000)).toBe('01.01.1870');
it('positive -> input negative number', () => {
expect(toDateString(NUMBER_NEGATIVE)).toBe('01.01.1870');
});

it('positive -> input negative number', () => {
expect(toDateString(946674000000)).toBe('01.01.2000');
it('positive -> input positive number', () => {
expect(toDateString(NUMBER_POSITIVE)).toBe('01.01.2000');
});

/**
Expand All @@ -37,12 +42,12 @@ describe('toISODateString', () => {
expect(toISODateString(0)).toBe('1970-01-01');
});

it('positive -> input positive number', () => {
expect(toISODateString(-3155682617000)).toBe('1870-01-01');
it('positive -> input negative number', () => {
expect(toISODateString(NUMBER_NEGATIVE)).toBe('1870-01-01');
});

it('positive -> input negative number', () => {
expect(toISODateString(946674000000)).toBe('2000-01-01');
it('positive -> input positive number', () => {
expect(toISODateString(NUMBER_POSITIVE)).toBe('2000-01-01');
});

/**
Expand Down

0 comments on commit ee9065d

Please sign in to comment.