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

♻️ vue-dot: Rename isDateAfterValue function to isDateAfter #1847

Merged
merged 1 commit into from
Mar 11, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- **rules:** Utilisation de la fonction `isDateBeforeValue` dans la règle de validation `notBeforeToday` ([#1827](https://github.com/assurance-maladie-digital/design-system/pull/1827)) ([35d4fb9](https://github.com/assurance-maladie-digital/design-system/commit/35d4fb90ecf882bb182e77d8894a2a78eac6a603))
- **global:** Suppression et mise à jour des commentaires ([#1829](https://github.com/assurance-maladie-digital/design-system/pull/1829)) ([976df56](https://github.com/assurance-maladie-digital/design-system/commit/976df56d938c0fb8d8eb5d3b8f02a073c9a17c09))
- **directives:** Refonte de la directive `debounce` ([#1830](https://github.com/assurance-maladie-digital/design-system/pull/1830)) ([2358e04](https://github.com/assurance-maladie-digital/design-system/commit/2358e045f6bc51b200b9f287f0267f52c65ec115))
- **functions:** Renommage de la function `isDateAfterValue` en `isDateAfter` ([#1847](https://github.com/assurance-maladie-digital/design-system/pull/1847))

- ♿️ **Accessibilité**
- **HeaderBar:** Ajout des attributs ARIA manquants ([#1844](https://github.com/assurance-maladie-digital/design-system/pull/1844)) ([7dbfced](https://github.com/assurance-maladie-digital/design-system/commit/7dbfceda3509cbc20921679be6cbff76a686ecf7))
Expand Down Expand Up @@ -147,7 +148,7 @@
- **DatePicker:** Mise à jour de la description de la prop `picker-date` ([#1768](https://github.com/assurance-maladie-digital/design-system/pull/1768)) ([be2dc4a](https://github.com/assurance-maladie-digital/design-system/commit/be2dc4a95a467e50d8d5f7dee71dc987035761a6))
- **global:** Mise à jour de la page principes de design ([#1770](https://github.com/assurance-maladie-digital/design-system/pull/1770)) ([5f69694](https://github.com/assurance-maladie-digital/design-system/commit/5f69694625d94489d238b5d389f60ccdc2833fad))
- **HeaderBar:** Mise à jour de l'exemple d'utilisation du slot par défaut ([#1838](https://github.com/assurance-maladie-digital/design-system/pull/1838)) ([8d921ef](https://github.com/assurance-maladie-digital/design-system/commit/8d921ef047a4553fc2c0026408e20842b748dc89))
- **HeaderBar:** Correction du nom du slot `secondary-logo` ([#1846](https://github.com/assurance-maladie-digital/design-system/pull/1846))
- **HeaderBar:** Correction du nom du slot `secondary-logo` ([#1846](https://github.com/assurance-maladie-digital/design-system/pull/1846)) ([0319f5f](https://github.com/assurance-maladie-digital/design-system/commit/0319f5f09b06739278a5c539277fae8860fa1ffc))

### Interne

Expand Down
9 changes: 0 additions & 9 deletions packages/vue-dot/src/functions/isDateAfterValue/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { parseDate } from '../../../helpers/parseDate';

/** Check if a date is after another date (DD/MM/YYYY format) */
export function isDateAfter(maxDate: string, value: string): boolean {
const parsedValue = parseDate(value);
const parsedMaxDate = parseDate(maxDate);

return parsedValue.isAfter(parsedMaxDate);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { isDateAfterValue } from '../';
import { isDateAfter } from '../';

import dayjs from 'dayjs';
import { formatDate } from '../../formatDate';
import { formatDate } from '../../../formatDate';

describe('isDateAfterValue', () => {
describe('isDateAfter', () => {
const today = formatDate(dayjs());
const pasteDate = formatDate(dayjs().subtract(1, 'year'));
const futureDate = formatDate(dayjs().add(1, 'year'));

it('returns true with a future date', () => {
expect(isDateAfterValue(today, futureDate)).toBeTruthy();
expect(isDateAfter(today, futureDate)).toBeTruthy();
});

it('returns false with a past date', () => {
expect(isDateAfterValue(today, pasteDate)).toBeFalsy();
expect(isDateAfter(today, pasteDate)).toBeFalsy();
});
});
4 changes: 2 additions & 2 deletions packages/vue-dot/src/rules/notAfterDate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { defaultErrorMessages } from './locales';

import { parseDate } from '../../helpers/parseDate';
import { formatDate } from '../../functions/formatDate';
import { isDateAfterValue } from '../../functions/isDateAfterValue';
import { isDateAfter } from '../../functions/validation/isDateAfter';

/** Check that the value is not after the specified date (DD/MM/YYYY format) */
export function notAfterDate(date: string, errorMessages = defaultErrorMessages): ValidationRule {
Expand All @@ -16,6 +16,6 @@ export function notAfterDate(date: string, errorMessages = defaultErrorMessages)

const formattedValue = formatDate(parseDate(date));

return !isDateAfterValue(date, value) || ruleMessage(errorMessages, 'default', [formattedValue]);
return !isDateAfter(date, value) || ruleMessage(errorMessages, 'default', [formattedValue]);
};
}
4 changes: 2 additions & 2 deletions packages/vue-dot/src/rules/notAfterToday/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ValidationRule, ValidationResult, ErrorMessages, Value } from '../types

import { defaultErrorMessages } from './locales';

import { isDateAfterValue } from '../../functions/isDateAfterValue';
import { isDateAfter } from '../../functions/validation/isDateAfter';
import { TODAY } from '../../constants';

/*** Check that the value is not after today (DD/MM/YYYY format) */
Expand All @@ -13,7 +13,7 @@ export function notAfterTodayFn(errorMessages: ErrorMessages = defaultErrorMessa
return true;
}

return !isDateAfterValue(TODAY, value) || ruleMessage(errorMessages, 'default');
return !isDateAfter(TODAY, value) || ruleMessage(errorMessages, 'default');
};
}

Expand Down