Skip to content

Commit

Permalink
Update deps (braintree#95)
Browse files Browse the repository at this point in the history
* chore: update dev dependencies

* chore: update nvmrc to node v14

* Remove accidental test addition
  • Loading branch information
crookedneighbor authored Jan 6, 2021
1 parent d1ed3bc commit 7af5a42
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '14.x'
- run: npm install
- run: npm test
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12
v14
151 changes: 70 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"license": "MIT",
"devDependencies": {
"@types/jest": "^26.0.19",
"@types/node": "^14.14.14",
"eslint": "^7.15.0",
"@types/node": "^14.14.20",
"eslint": "^7.17.0",
"eslint-config-braintree": "^5.0.0-typescript-prep-rc.18",
"jest": "^26.6.3",
"prettier": "^2.2.1",
Expand Down
110 changes: 0 additions & 110 deletions src/__tests__/expiration-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1264,116 +1264,6 @@ describe("expirationDate validates", () => {
);
});

describe("potentiallyValid state for 2 digit year", () => {
it("should be isValid: false and isPotentiallyValid: true when MM/YY format is not valid, but adding 2 more characters to make it MM/YYYY would be", () => {
const firstTwoDigitsOfCurrentYear = String(currentYear).substr(0, 2);

expect(expirationDate(`1 / ${firstTwoDigitsOfCurrentYear}`)).toEqual({
isValid: false,
isPotentiallyValid: true,
month: "1",
year: firstTwoDigitsOfCurrentYear,
});

let count = 0;
let hasSomeFutureValidValue = false;

while (count < 100) {
let stringCount = String(count);
if (count < 10) {
stringCount = `0${stringCount}`;
}

const isValid = expirationDate(
`1 / ${firstTwoDigitsOfCurrentYear}${stringCount}`
).isValid;

if (isValid) {
hasSomeFutureValidValue = true;
break;
}

count++;
}

expect(hasSomeFutureValidValue).toBe(true);
});

it("should be isValid: false and isPotentiallyValid: false when MM/YY format is not valid, but adding 2 more characters to make it MM/YYYY would still be too far into the future no matter what the final result", () => {
const firstTwoDigitsOfCurrentYearPlus2000 = String(
currentYear + 2000
).substr(0, 2);

expect(
expirationDate(`1 / ${firstTwoDigitsOfCurrentYearPlus2000}`)
).toEqual({
isValid: false,
isPotentiallyValid: false,
month: null,
year: null,
});

let count = 0;

while (count < 100) {
let stringCount = String(count);
if (count < 10) {
stringCount = `0${stringCount}`;
}

expect(
expirationDate(
`1 / ${firstTwoDigitsOfCurrentYearPlus2000}${stringCount}`
)
).toEqual({
isValid: false,
isPotentiallyValid: false,
month: null,
year: null,
});

count++;
}
});

it("should be isValid: false and isPotentiallyValid: false when MM/YY format is not valid, but adding 2 more characters to make it MM/YYYY would still be too far back in the past no matter what the final result", () => {
const firstTwoDigitsOfCurrentYearMinus1000 = String(
currentYear - 1000
).substr(0, 2);

expect(
expirationDate(`1 / ${firstTwoDigitsOfCurrentYearMinus1000}`)
).toEqual({
isValid: false,
isPotentiallyValid: false,
month: null,
year: null,
});

let count = 0;

while (count < 100) {
let stringCount = String(count);
if (count < 10) {
stringCount = `0${stringCount}`;
}

expect(
expirationDate(
`1 / ${firstTwoDigitsOfCurrentYearMinus1000}${stringCount}`
)
).toEqual({
isValid: false,
isPotentiallyValid: false,
month: null,
year: null,
});

count++;
}
});
});

describe("maxElapsedYear", () => {
it("defaults maxElapsedYear is 19", () => {
expect(expirationDate(`${currentMonth} / ${yearsFromNow(19)}`)).toEqual({
Expand Down

0 comments on commit 7af5a42

Please sign in to comment.