| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- describe('meid', function() {
- beforeEach(function() {
- $([
- '<form class="form-horizontal" id="meidForm">',
- '<div class="form-group">',
- '<input type="text" name="meid" data-bv-meid />',
- '</div>',
- '</form>'
- ].join('\n')).appendTo('body');
- $('#meidForm').bootstrapValidator();
- this.bv = $('#meidForm').data('bootstrapValidator');
- this.$meid = this.bv.getFieldElements('meid');
- });
- afterEach(function() {
- $('#meidForm').bootstrapValidator('destroy').remove();
- });
- it('Valid MEID (14 hex, check digit)', function() {
- this.bv.resetForm();
- this.$meid.val('A00000049259B16');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (14 hex, dashes, check digit)', function() {
- this.bv.resetForm();
- this.$meid.val('A0-000004-9259B1-6');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (14 hex, spaces, check digit)', function() {
- this.bv.resetForm();
- this.$meid.val('A0 000004 9259B1 6');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (18 dec, check digit)', function() {
- this.bv.resetForm();
- this.$meid.val('2936087365007037100');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (18 dec, dashes, check digit)', function() {
- this.bv.resetForm();
- this.$meid.val('29360-87365-0070-3710-0');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (18 dec, spaces, check digit)', function() {
- this.bv.resetForm();
- this.$meid.val('29360 87365 0070 3710 0');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (14 hex)', function() {
- this.bv.resetForm();
- this.$meid.val('AF0123450ABCDE');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (14 hex, dashes)', function() {
- this.bv.resetForm();
- this.$meid.val('AF-012345-0ABCDE');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (14 hex, spaces)', function() {
- this.bv.resetForm();
- this.$meid.val('AF 012345 0ABCDE');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (18 dec)', function() {
- this.bv.resetForm();
- this.$meid.val('293608736500703710');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (18 dec, dashes)', function() {
- this.bv.resetForm();
- this.$meid.val('29360-87365-0070-3710');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Valid MEID (18 dec, spaces)', function() {
- this.bv.resetForm();
- this.$meid.val('29360 87365 0070 3710');
- this.bv.validate();
- expect(this.bv.isValid()).toBeTruthy();
- });
- it('Invalid MEID (14 hex, bad check digit)', function() {
- this.bv.resetForm();
- this.$meid.val('A00000049259B15');
- this.bv.validate();
- expect(this.bv.isValid()).toBeFalsy();
- });
- it('Invalid MEID (13 hex)', function() {
- this.bv.resetForm();
- this.$meid.val('A00000049259B');
- this.bv.validate();
- expect(this.bv.isValid()).toBeFalsy();
- });
- it('Invalid MEID (18 dec, bad check digit)', function() {
- this.bv.resetForm();
- this.$meid.val('2936087365007037101');
- this.bv.validate();
- expect(this.bv.isValid()).toBeFalsy();
- });
- it('Invalid MEID (17 dec)', function() {
- this.bv.resetForm();
- this.$meid.val('29360873650070371');
- this.bv.validate();
- expect(this.bv.isValid()).toBeFalsy();
- });
- });
|