Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[test] Update the test suite to use .truncate instead of .pan

  • Loading branch information...
commit bdae81dc5dff91477e1245d36cc8836b234fd4cb 1 parent d4f596d
@3rd-Eden 3rd-Eden authored
Showing with 7 additions and 7 deletions.
  1. +1 −1  lib/creditcard.js
  2. +6 −6 test/creditcard.test.js
View
2  lib/creditcard.js
@@ -201,7 +201,7 @@ exports.parse = function parse(number) {
, cvv: scheme === 'American Express'
? 4 // American Express requires 4 digits
: 3 // All other credit cards
- , pan: exports.pan(number) // PAN truncated version
+ , truncate: exports.truncate(number) // PAN truncated version
, scheme: scheme // Creditcard scheme
, validates: exports.validate(number) // Does the creditcard validate
};
View
12 test/creditcard.test.js
@@ -54,17 +54,17 @@ describe('creditcard#format', function () {
});
});
-describe('creditcard#pan', function () {
+describe('creditcard#truncate', function () {
it('should handle Amerian Express', function () {
- expect(creditcard.pan('378282246310005')).to.equal('XXXX XXXXXX X0005');
+ expect(creditcard.truncate('378282246310005')).to.equal('XXXX XXXXXX X0005');
});
it('should formot all other credit card formats', function () {
- expect(creditcard.pan('4111111111111111')).to.equal('XXXX XXXX XXXX 1111');
+ expect(creditcard.truncate('4111111111111111')).to.equal('XXXX XXXX XXXX 1111');
});
it('should also truncate credit card numbers with less chars correctly', function () {
- expect(creditcard.pan('4222222222222')).to.equal('XXXX XXXX X222 2');
+ expect(creditcard.truncate('4222222222222')).to.equal('XXXX XXXX X222 2');
});
});
@@ -75,7 +75,7 @@ describe('creditcard#parse', function () {
expect(data).to.have.property('iin');
expect(data).to.have.property('mii');
expect(data).to.have.property('cvv');
- expect(data).to.have.property('pan');
+ expect(data).to.have.property('truncate');
expect(data).to.have.property('scheme');
expect(data).to.have.property('formatted');
expect(data).to.have.property('validates');
@@ -87,7 +87,7 @@ describe('creditcard#parse', function () {
expect(data.iin).to.equal('411111111');
expect(data.mii).to.equal('Banking and financial');
expect(data.cvv).to.equal(3);
- expect(data.pan).to.equal('XXXX XXXX XXXX 1111');
+ expect(data.truncate).to.equal('XXXX XXXX XXXX 1111');
expect(data.scheme).to.equal('Visa');
expect(data.formatted).to.equal('4111 1111 1111 1111');
expect(data.validates).to.equal(true);
Please sign in to comment.
Something went wrong with that request. Please try again.