<commit_before>"use strict"

var _             = require("lodash")
  , expect        = require("chai").expect
  , ubivar        = require("../../ubivar")
  , Ubivar        = require("../../../lib")
  , version       = ubivar._api.request.version
  , token         = process.env.UBIVAR_TEST_TOKEN

console.log("\n\n\nVERSION", version, "\n\n\n")

describe("Me", function(){
  var testIt      = function(token, isAuthorized){
    var message   = "Should be " + (isAuthorized?"  ":"un") + "authorized "
    message       += !!token ? ("'"+token.slice(0,5)+"...'") : ("'"+token+"'")

    it(message, function(done){
      var ubivar  = Ubivar(token, version)
      ubivar.set("timeout", 20000)

      ubivar.me.retrieve(function(gotError, res){
        if( isAuthorized &&  gotError){console.log(gotError); done((new Error(message)))}
        if( isAuthorized && !gotError) done()
        if(!isAuthorized &&  gotError) done()
        if(!isAuthorized && !gotError){console.log(gotError); done((new Error(message)))}
      })
    })
  }

  testIt(null         , false)
  testIt(undefined    , false)
  testIt("unauthToken", false)
  testIt(token, true)

  it("Should update me", function(done){
    var ubivar        = new Ubivar(token, version)
      , vrand         = ""+Math.random()

    ubivar.me.update({"primary_phone": vrand}, function(err, res){
      if(!err && res.status === 200 && vrand === res.data[0]["primary_phone"]){
        return done()
      } 

      console.log("\n\nError:", err
      , "\nResponse:"         , res
      , "\nVrand:"            , vrand)
      done(new Error("Should update me"))
    })
  })

  it("Should fail to delete me", function(done){
    var ubivar    = new Ubivar(token, version)
    ubivar.me.del(function(err, res){
      if(err){
        done()
      } else {
        done(new Error("Should fail to delete 'me'!"))
      }
    })
  })

  it("Should list a single me", function(done){
    var ubivar    = new Ubivar(token, version)
    ubivar.me.list(function(err, res){
      if(!err && res.status === 200 && res.data.length === 1){
        done()

      } else {
        console.log("\n\nError:", err
        , "\nResponse:"         , res)
        done(new Error("Should list a single me"))
      }
    })
  })
})<commit_msg>Discard LIST of resource ME<commit_after>"use strict"

var _             = require("lodash")
  , expect        = require("chai").expect
  , ubivar        = require("../../ubivar")
  , Ubivar        = require("../../../lib")
  , version       = ubivar._api.request.version
  , token         = process.env.UBIVAR_TEST_TOKEN

console.log("\n\n\nVERSION", version, "\n\n\n")

describe("Me", function(){
  var testIt      = function(token, isAuthorized){
    var message   = "Should be " + (isAuthorized?"  ":"un") + "authorized "
    message       += !!token ? ("'"+token.slice(0,5)+"...'") : ("'"+token+"'")

    it(message, function(done){
      var ubivar  = Ubivar(token, version)
      ubivar.set("timeout", 20000)

      ubivar.me.retrieve(function(gotError, res){
        if( isAuthorized &&  gotError){console.log(gotError); done((new Error(message)))}
        if( isAuthorized && !gotError) done()
        if(!isAuthorized &&  gotError) done()
        if(!isAuthorized && !gotError){console.log(gotError); done((new Error(message)))}
      })
    })
  }

  testIt(null         , false)
  testIt(undefined    , false)
  testIt("unauthToken", false)
  testIt(token, true)

  it("Should update me", function(done){
    var ubivar        = new Ubivar(token, version)
      , vrand         = ""+Math.random()

    ubivar.me.update({"primary_phone": vrand}, function(err, res){
      if(!err && res.status === 200 && vrand === res.data[0]["primary_phone"]){
        return done()
      } 

      console.log("\n\nError:", err
      , "\nResponse:"         , res
      , "\nVrand:"            , vrand)
      done(new Error("Should update me"))
    })
  })

  it("Should fail to delete me", function(done){
    var ubivar    = new Ubivar(token, version)
    ubivar.me.del(function(err, res){
      if(err){
        done()
      } else {
        done(new Error("Should fail to delete 'me'!"))
      }
    })
  })
})
{'fraction_non_alphanumeric': 0.18088410991636797, 'fraction_numerical': 0.006212664277180406, 'mean_word_length': 2.362248995983936, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5687178', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1377, 'n_words': 278}