specTest.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. describe("IDValidator test", function(){
  2. var testId = "371001198010082394";
  3. var fakeId = "345955198706122245";
  4. var fifteenId = "431389760616601";
  5. var Validator = new IDValidator();
  6. var makeID = Validator.makeID();
  7. it( fakeId+" should be a FAKE ID", function() {
  8. expect( Validator.isValid(fakeId) ).toBe(false);
  9. });
  10. it( testId+" should be a REAL ID", function() {
  11. expect( Validator.isValid(testId) ).toBe(true);
  12. });
  13. it( testId+" should be a MALE ID", function() {
  14. expect( Validator.getInfo(testId).sex ).toBe(1);
  15. });
  16. it( testId+" birth is 1980-10-08", function() {
  17. expect( Validator.getInfo(testId).birth ).toEqual('1980-10-08');
  18. });
  19. it( fifteenId+" should be a 15 ID", function() {
  20. expect( Validator.getInfo(fifteenId).length ).toBe(15);
  21. });
  22. it( "the maked ID "+makeID+" should be a REAL ID", function() {
  23. expect( Validator.isValid(makeID) ).toBe(true);
  24. });
  25. it( " limited 18 ID", function() {
  26. expect( Validator.isValid(fifteenId) ).toBe(true);
  27. expect( Validator.isValid(fifteenId, 18) ).toBe(false);
  28. expect( typeof Validator.getInfo(fifteenId) ).toBe("object");
  29. expect( Validator.getInfo(fifteenId, 18) ).toBe(false);
  30. });
  31. });