SHARE
TWEET

Untitled

a guest May 23rd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var personCustomValidators = {
  2.         toBeOlderThan: function(){
  3.             return {
  4.                 compare: function(actualAge, expectAge) {
  5.                     var result = {pass:false,message:''};
  6.                     if (actualAge > expectAge){
  7.                         result.pass = true;
  8.                         result.message = "test is passed"
  9.                     } else {
  10.                         result.pass = false;
  11.                         result.message = "test fails"
  12.                     }
  13.                     return result;
  14.                 }
  15.             }
  16.         },
  17.         toBeFirstNameEqualTo: function() {
  18.             return {
  19.                 compare: function(actual, expected) {
  20.                     var result = {pass:false,message:''};
  21.                     var firstName = actual.split(' ')[0];
  22.                     if (firstName == expected){
  23.                         result.pass = true;
  24.                         result.message = "test is passed"
  25.                     } else {
  26.                         result.pass = false;
  27.                         result.message = "test fails"
  28.                     }
  29.                     return result;
  30.                 }
  31.             }
  32.         },
  33.         toBeLastNameEqualTo: function() {
  34.             return {
  35.                 compare: function(actual, expected) {
  36.                     var result = {pass:false,message:''};
  37.                     var firstName = actual.split(' ')[1];
  38.                     if (firstName == expected){
  39.                         result.pass = true;
  40.                         result.message = "test is passed"
  41.                     } else {
  42.                         result.pass = false;
  43.                         result.message = "test fails"
  44.                     }
  45.                     return result;
  46.                 }
  47.             }
  48.         }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top