Sha256: 5dc5adb33d5308da586a7fecd4bc5f364607a9303095a26a194050e34b73c88f

Contents?: true

Size: 1.87 KB

Versions: 121

Compression:

Stored size: 1.87 KB

Contents

var ISBN = require('./isbn-verifier');

describe('ISBN', function () {
  it('valid isbn number', function () {
    var isbn = new ISBN('3-598-21508-8');
    expect(isbn.isValid()).toBe(true);
  });

  it('invalid isbn check digit', function () {
    var isbn = new ISBN('3-598-21508-9');
    expect(isbn.isValid()).toBe(false);
  });

  it('valid isbn number with a check digit of 10', function () {
    var isbn = new ISBN('3-598-21507-X');
    expect(isbn.isValid()).toBe(true);
  });

  it('check digit is a character other than X', function () {
    var isbn = new ISBN('3-598-21507-A');
    expect(isbn.isValid()).toBe(false);
  });

  it('invalid character in isbn', function () {
    var isbn = new ISBN('3-598-2K507-0');
    expect(isbn.isValid()).toBe(false);
  });

  it('X is only valid as a check digit', function () {
    var isbn = new ISBN('3-598-2X507-0');
    expect(isbn.isValid()).toBe(false);
  });

  it('valid isbn without separating dashes', function () {
    var isbn = new ISBN('3598215088');
    expect(isbn.isValid()).toBe(true);
  });

  it('isbn without separating dashes and X as check digit', function () {
    var isbn = new ISBN('359821507X');
    expect(isbn.isValid()).toBe(true);
  });

  it('isbn without check digit and dashes', function () {
    var isbn = new ISBN('359821507');
    expect(isbn.isValid()).toBe(false);
  });

  it('too long isbn and no dashes', function () {
    var isbn = new ISBN('3598215078X');
    expect(isbn.isValid()).toBe(false);
  });

  it('isbn without check digit', function () {
    var isbn = new ISBN('3-598-21507');
    expect(isbn.isValid()).toBe(false);
  });

  it('too long isbn', function () {
    var isbn = new ISBN('3-598-21507-XA');
    expect(isbn.isValid()).toBe(false);
  });

  it('check digit of X should not be used for 0', function () {
    var isbn = new ISBN('3-598-21515-X');
    expect(isbn.isValid()).toBe(false);
  });
});

Version data entries

121 entries across 121 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.179 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.178 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.177 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.176 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.175 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.174 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.173 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.172 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.171 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.170 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.169 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.167 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.166 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.165 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.164 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.163 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.162 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.161 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js
trackler-2.2.1.160 tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js