<commit_before>ahoy = require("../dist/ahoy.js").ahoy

checkSource = (referrer, name, category, extra=null) ->
  source = ahoy.parseReferrer(referrer)
  expect(source.name).toEqual(name)
  expect(source.category).toEqual(category)
  expect(source.extra).toEqual(extra)

describe "ahoy", ->

  describe "sources", ->

    it "direct", ->
      checkSource "", "(direct)", "(direct)"

    it "google organic", ->
      checkSource "http://www.google.com/?q=test", "google.com", "search", "test"

    it "google paid", ->
      checkSource "http://www.google.com/aclk?q=test", "google.com", "paid search", "test"

    it "facebook", ->
      checkSource "http://www.facebook.com/l.php", "facebook.com", "referral"

    it "facebook ad", ->
      checkSource "http://www.facebook.com/ajax/emu/end.php", "facebook.com", "ad"

    it "bing organic", ->
      checkSource "http://www.bing.com/?q=test", "bing.com", "search", "test"

    it "doubleclick", ->
      checkSource "http://googleads.g.doubleclick.net/pagead/ads?url=http%3A//www.example.org", "example.org", "ad", "doubleclick"
<commit_msg>Added referral test<commit_after>ahoy = require("../dist/ahoy.js").ahoy

checkSource = (referrer, name, category, extra=null) ->
  source = ahoy.parseReferrer(referrer)
  expect(source.name).toEqual(name)
  expect(source.category).toEqual(category)
  expect(source.extra).toEqual(extra)

describe "ahoy", ->

  describe "sources", ->

    it "direct", ->
      checkSource "", "(direct)", "(direct)"

    it "referral", ->
      checkSource "http://www.example.org", "example.org", "referral"

    it "google organic", ->
      checkSource "http://www.google.com/?q=test", "google.com", "search", "test"

    it "google paid", ->
      checkSource "http://www.google.com/aclk?q=test", "google.com", "paid search", "test"

    it "facebook", ->
      checkSource "http://www.facebook.com/l.php", "facebook.com", "referral"

    it "facebook ad", ->
      checkSource "http://www.facebook.com/ajax/emu/end.php", "facebook.com", "ad"

    it "bing organic", ->
      checkSource "http://www.bing.com/?q=test", "bing.com", "search", "test"

    it "doubleclick", ->
      checkSource "http://googleads.g.doubleclick.net/pagead/ads?url=http%3A//www.example.org", "example.org", "ad", "doubleclick"

{'fraction_non_alphanumeric': 0.20332313073895933, 'fraction_numerical': 0.0008745080891998251, 'mean_word_length': 3.5306930693069307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 13, 'xml': 0}, 'pii_count': 0, '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': '6053238', 'n_tokens_mistral': 783, 'n_tokens_neox': 768, 'n_words': 140}