Write full test coverage for the Switch

PHOTO EMBED

Fri May 21 2021 14:56:41 GMT+0000 (Coordinated Universal Time)

Saved by @ejiwen

// Write full test coverage for the Switch
describe('Switch', function() {
  // Switch with prefix of 564182 or 633110
  var switchPrefix = [564182, 633110];
  for (var prefixIndex = 0; prefixIndex < switchPrefix.length; prefixIndex++) {
    (function(currentIndex) {
      it('has a prefix of ' + switchPrefix[currentIndex] + ' and a length of 16', function() {
        detectNetwork(switchPrefix[currentIndex] + '1234567890').should.equal('Switch');
      });
      it('has a prefix of ' + switchPrefix[currentIndex] + ' and a length of 18', function() {
        detectNetwork(switchPrefix[currentIndex] + '123456789012').should.equal('Switch');
      });
      it('has a prefix of ' + switchPrefix[currentIndex] + ' and a length of 19', function() {
        detectNetwork(switchPrefix[currentIndex] + '1234567890123').should.equal('Switch');
      });
    })(prefixIndex);
  }
  // Switch with prefix of 4903, 4905, 4911, 4936, 6333 or 6759
  var switchPrefix2 = [4903, 4905, 4911, 4936, 6333, 6759];
  for (var prefixIndex = 0; prefixIndex < switchPrefix2.length; prefixIndex++) {
    (function(currentIndex) {
      it('has a prefix of ' + switchPrefix2[currentIndex] + ' and a length of 16', function() {
        detectNetwork(switchPrefix2[currentIndex] + '123456789012').should.equal('Switch');
      });
      it('has a prefix of ' + switchPrefix2[currentIndex] + ' and a length of 18', function() {
        detectNetwork(switchPrefix2[currentIndex] + '12345678901234').should.equal('Switch');
      });
      it('has a prefix of ' + switchPrefix2[currentIndex] + ' and a length of 19', function() {
        detectNetwork(switchPrefix2[currentIndex] + '123456789012345').should.equal('Switch');
      });
    })(prefixIndex);
  }
});
content_copyCOPY