Skip to content

Commit

Permalink
Migrating date-aux.js
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoarthur0 committed Mar 9, 2024
1 parent 6346965 commit ed01146
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions __tests__/__main__/date-aux.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-undef */
'use strict';

const assert = require('assert');
import assert from 'assert';

import { getDateStr, getCurrentDateTimeStr, getMonthLength } from '../../js/date-aux.js';

describe('Date Functions', () =>
Expand All @@ -12,12 +13,12 @@ describe('Date Functions', () =>

describe('getDateStr(Date())', () =>
{
test('Given a JS Date() object, should return YYYY-MM-DD', () =>
it('Given a JS Date() object, should return YYYY-MM-DD', () =>
{
assert.strictEqual(getDateStr(testDate), expectedDate);
});

test('Given an insane object, should return an error', () =>
it('Given an insane object, should return an error', () =>
{
assert.notStrictEqual(getDateStr(badDate), expectedDate);
});
Expand All @@ -26,7 +27,7 @@ describe('Date Functions', () =>
describe('getMonthLength(Year, Month)', () =>
{
const testYear = 2024;
test('Given for the Year(2024) and Months, should return number of days in month', () =>
it('Given for the Year(2024) and Months, should return number of days in month', () =>
{
assert.strictEqual(getMonthLength(testYear, 0), 31);
assert.strictEqual(getMonthLength(testYear, 1), 29);
Expand All @@ -48,12 +49,12 @@ describe('Date Functions', () =>
const looseRegexCurrentDateTime = /(\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2})/g;
const regexCurrentDateTime = /(\d{4}_(0[1-9]|1[0-2])_(0[1-9]|[12]\d|3[01])_(0\d|1\d|2[0-3])_([0-5]\d)_([0-5]\d))/g;

test('Should return Current Date Time string in YYYY_MM_DD_HH_MM_SS format with no spaces or unexpected characters making sure it accepts digits', () =>
it('Should return Current Date Time string in YYYY_MM_DD_HH_MM_SS format with no spaces or unexpected characters making sure it accepts digits', () =>
{
assert.strictEqual(looseRegexCurrentDateTime.test(getCurrentDateTimeStr()), true);
});

test('Should return Current Date Time string in YYYY_MM_DD_HH_MM_SS format with no spaces or unexpected characters', () =>
it('Should return Current Date Time string in YYYY_MM_DD_HH_MM_SS format with no spaces or unexpected characters', () =>
{
assert.strictEqual(regexCurrentDateTime.test(getCurrentDateTimeStr()), true);
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/electron-mocha-main.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const data = require('./mocha-base.config.cjs');

data.spec = ['__tests__/__main__/{time-math,validate-json}.js'];
data.spec = ['__tests__/__main__/{date-aux,time-math,validate-json}.js'];

module.exports = data;
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
displayName: ' MAIN',
runner: '@jest-runner/electron/main',
testEnvironment: 'node',
testMatch: ['**/__tests__/**main**/*.js', '!**/{time-math,validate-json}.js']
testMatch: ['**/__tests__/**main**/*.js', '!**/{date-aux,time-math,validate-json}.js']
},
{
displayName: 'RENDERER',
Expand Down

0 comments on commit ed01146

Please sign in to comment.