Skip to content
This repository has been archived by the owner on Nov 16, 2018. It is now read-only.

Commit

Permalink
v2.0.1
Browse files Browse the repository at this point in the history
- Fixed unit tests
- Fixed expired functionality
  • Loading branch information
dhershman committed Mar 21, 2018
1 parent b8a651f commit 02a3b1c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v2.0.1

- Fixed all unit tests to actually get full year
- Fixed expired functionality to be able to handle invalid dates

## v2.0.0

#### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-card",
"version": "2.0.0",
"version": "2.0.1",
"description": "a simple plug and play credit card validation library using the lugn algorithm",
"main": "simple-card.min.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion src/expired/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const expired = date => {

const currDate = generateDate();
const expireDate = new Date(normalizeDate(date));
const isExpired = currDate > expireDate;
const isExpired = !isNaN(expireDate) ? currDate > expireDate : true;

return {
isValid: !isExpired,
Expand Down
9 changes: 8 additions & 1 deletion src/expired/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import test from 'ava';
const today = new Date();

test('Test Date validation', t => {
const { isValid, isExpired } = expired(`${today.getMonth() + 1}/${today.getFullYear}`);
const { isValid, isExpired } = expired(`${today.getMonth() + 1}/${today.getFullYear()}`);

t.true(isValid, 'Is a valid date');
t.false(isExpired, 'Not Expired');
Expand Down Expand Up @@ -32,3 +32,10 @@ test('Throws type error when given date object', t => {

t.is(err.message, 'date should be a string type');
});

test('Throws type error when given date object', t => {
const results = expired('21/21');

t.true(results.isExpired);
t.false(results.isValid);
});
2 changes: 1 addition & 1 deletion src/validate/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import simpleCard from './index';
import test from 'ava';

const today = new Date();
const currDate = `${today.getMonth() + 1}/${today.getFullYear}`;
const currDate = `${today.getMonth() + 1}/${today.getFullYear()}`;

const validData = {
visaCard: {
Expand Down

0 comments on commit 02a3b1c

Please sign in to comment.