Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-12882: Adding & removing a relationship date shows pending edits #2831

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion root/static/scripts/common/utility/areDatesEqual.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
* later version: http://www.gnu.org/licenses/gpl-2.0.txt
*/

import isDateEmpty from './isDateEmpty.js';

export default function areDatesEqual(
a: PartialDateT | null,
b: PartialDateT | null,
): boolean %checks {
return (a === null && b === null) || (
return (isDateEmpty(a) && isDateEmpty(b)) || (
a !== null && b !== null &&
a.year === b.year && a.month === b.month && a.day === b.day
);
Expand Down
19 changes: 19 additions & 0 deletions root/static/scripts/tests/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import test from 'tape';

import * as age from '../../../utility/age.js';
import formatUserDate from '../../../utility/formatUserDate.js';
import {
EMPTY_PARTIAL_DATE,
} from '../common/constants.js';
import areDatesEqual from '../common/utility/areDatesEqual.js';
import compareDates, {
compareDatePeriods,
} from '../common/utility/compareDates.js';
Expand Down Expand Up @@ -97,6 +101,21 @@ test('age', function (t) {
}), [1, 0, 1], 'age with partial dates is 1 year, 1 day');
});

test('areDatesEqual', function (t) {
t.plan(7);

const date1 = {year: 2000, month: 1, day: 1};
const date2 = {year: 2000, month: 11, day: 1};

t.ok(areDatesEqual(null, null));
t.ok(areDatesEqual(EMPTY_PARTIAL_DATE, null));
t.ok(areDatesEqual(null, EMPTY_PARTIAL_DATE));
t.ok(areDatesEqual(EMPTY_PARTIAL_DATE, EMPTY_PARTIAL_DATE));
t.ok(areDatesEqual(date1, date1));
t.ok(areDatesEqual(date2, date2));
t.ok(!areDatesEqual(date1, date2));
});

test('compareDates', function (t) {
t.plan(7);

Expand Down