<commit_before>var validate = require('../validator')()
  , async = require('async')
  , should = require('should')

describe('URL Validation', function() {

  it('should correctly validate valid URLs', function (done) {
    var urls =
    [ 'http://www.google.com'
    , 'https://www.google.com'
    ,  'http://google.com'
    ,  'https://google.com'
    ,  'http://asddasads.google.com'
    ,  'http://asddasads.google.com/asddasads'
    ,  'http://asddasads.google.com/asddasads/asdass'
    ,  'http://asddasads.google.com/asddasads/asdass#'
    ,  'http://asddasads.google.com/asddasads/asdass?a=b'
    ,  'http://asddasads.google.com/asddasads/asdass?a=b#asdasd'
    ,  'http://a.co'
    ,  'http://user:password@a.com'
    ,  'http://user:password@a.com?f=b&b=a'
    ,  'http://user:password@www.a.com?f=b&b=a'
    ,  'http://user:password@www.a.a.a.a.a.a.a.a.a.a.a.a.com/mypage.html?f=b&b=a#'
    ,  'http://localhost'
    ,  'http://localhost:80'
    ,  'ftp://localhost:21'
    ,  'http://localhost/test'
    ,  'http://intranet:80'
    ,  'http://intranet:80/test'
    ]

    async.each(urls, function (value, cb) {
      validate('url', 'url', { url: value }, function (err, errMessage) {
        if (err) return cb(err)
        should.not.exist(errMessage)

        cb(err)
      })
    }, function (err) {
      done(err)
    })

  })

  it('should correctly return false for invaild URLs', function (done) {
    var urls = 
    [ 'google.com'
    , 'sfsdfsd'
    , 'http://'
    , 'www.fred.com'
    , 'google.com/asddasads/asdass?a=b#asdasd'
    , 'localhost'
    , 'localhost:80'
    ,  null
    , undefined
    , ''
    ,  new Date()
    ,  1
    ,  '1'
    ]

    async.each(urls, function(value, cb) {
      validate('url', 'url', { url: value }, function (err, errMessage) {
        if (err) return cb(err)
        
        errMessage.should.equal('url must be a valid URL')

        cb(err)
      })
    }, function (err) {
      done(err)
    })

  })

})<commit_msg>Better reporting when a fixtures fails<commit_after>var validate = require('../validator')()
  , async = require('async')
  , should = require('should')

describe('URL Validation', function() {

  it('should correctly validate valid URLs', function (done) {
    var urls =
    [ 'http://www.google.com'
    , 'https://www.google.com'
    ,  'http://google.com'
    ,  'https://google.com'
    ,  'http://asddasads.google.com'
    ,  'http://asddasads.google.com/asddasads'
    ,  'http://asddasads.google.com/asddasads/asdass'
    ,  'http://asddasads.google.com/asddasads/asdass#'
    ,  'http://asddasads.google.com/asddasads/asdass?a=b'
    ,  'http://asddasads.google.com/asddasads/asdass?a=b#asdasd'
    ,  'http://a.co'
    ,  'http://user:password@a.com'
    ,  'http://user:password@a.com?f=b&b=a'
    ,  'http://user:password@www.a.com?f=b&b=a'
    ,  'http://user:password@www.a.a.a.a.a.a.a.a.a.a.a.a.com/mypage.html?f=b&b=a#'
    ,  'http://localhost'
    ,  'http://localhost:80'
    ,  'ftp://localhost:21'
    ,  'http://localhost/test'
    ,  'http://intranet:80'
    ,  'http://intranet:80/test'
    ]

    async.each(urls, function (value, cb) {
      validate('url', 'url', { url: value }, function (err, errMessage) {
        if (err) return cb(err)
        should.not.exist(errMessage, 'Should be valid: ' + value)

        cb(err)
      })
    }, function (err) {
      done(err)
    })

  })

  it('should correctly return false for invaild URLs', function (done) {
    var urls =
    [ 'google.com'
    , 'sfsdfsd'
    , 'http://'
    , 'www.fred.com'
    , 'google.com/asddasads/asdass?a=b#asdasd'
    , 'localhost'
    , 'localhost:80'
    ,  null
    , undefined
    , ''
    ,  new Date()
    ,  1
    ,  '1'
    ]

    async.each(urls, function(value, cb) {
      validate('url', 'url', { url: value }, function (err, errMessage) {
        if (err) return cb(err)
        should.ok(errMessage, 'This is considered a value URL ' + value)
        errMessage.should.equal('url must be a valid URL')

        cb(err)
      })
    }, function (err) {
      done(err)
    })

  })

})
{'fraction_non_alphanumeric': 0.19633699633699633, 'fraction_numerical': 0.005860805860805861, 'mean_word_length': 2.376751854905194, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4028240', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1598, 'n_words': 233}