Skip to content

Instantly share code, notes, and snippets.

@pushkar100
Last active June 24, 2022 14:58
Show Gist options
  • Save pushkar100/34b994c8a77c63141045794457bf4922 to your computer and use it in GitHub Desktop.
Save pushkar100/34b994c8a77c63141045794457bf4922 to your computer and use it in GitHub Desktop.
/* src/__tests__/helpers/index.test.js: */
import { isEarlierThanNow } from '../../helpers';
test('isEarlierThanNow, given a timestamp earlier than now, retruns true', () => {
// Arrange
const date = new Date('1/1/2000');
// Act
const actualIsEarlierDateThanNow = isEarlierThanNow(date);
// Assert
expect(actualIsEarlierDateThanNow).toEqual(true);
});
test('isEarlierThanNow, given a timestamp greater than now, returns false', () => {
// Arrange
const date = new Date('1/1/2060');
// Act
const actualIsEarlierDateThanNow = isEarlierThanNow(date);
// Assert
expect(actualIsEarlierDateThanNow).toEqual(false);
});
test('isEarlierThanNow, given a timestamp equal to now, returns false', () => {
// Arrange
const date = Date.now();
// Act
const actualIsEarlierDateThanNow = isEarlierThanNow(date);
// Assert
expect(actualIsEarlierDateThanNow).toEqual(false);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment