<commit_before>var vows = require('vows');
var assert = require('assert');
var util = require('util');
var XingStrategy = require('passport-xing/strategy');


vows.describe('XingStrategy').addBatch({
  
  'strategy': {
    topic: function() {
      return new XingStrategy({
        consumerKey: 'ABC123',
        consumerSecret: 'secret'
      },
      function() {});
    },
    
    'should be named xing': function (strategy) {
      assert.equal(strategy.name, 'xing');
    },
  },
  
  'strategy when loading user profile': {
    topic: function() {
      var strategy = new XingStrategy({
        consumerKey: 'ABC123',
        consumerSecret: 'secret'
      },
      function() {});
      
      // mock
      strategy._oauth.get = function(url, token, tokenSecret, callback) {
        var body = '{ "firstName": "Jared", "id": "_XX0XXX00X", "lastName": "Hanson" }';
        
        callback(null, body, undefined);
      }
      
      return strategy;
    },
    
    'when told to load user profile': {
      topic: function(strategy) {
        var self = this;
        function done(err, profile) {
          self.callback(err, profile);
        }
        
        process.nextTick(function () {
          strategy.userProfile('token', 'token-secret', {}, done);
        });
      },
      
      'should not error' : function(err, req) {
        assert.isNull(err);
      },
      'should load profile' : function(err, profile) {<commit_msg>Adapt Unittests to reflect Xing behaviour<commit_after>var vows = require('vows');
var assert = require('assert');
var util = require('util');
var XingStrategy = require('passport-xing/strategy');


vows.describe('XingStrategy').addBatch({
  
  'strategy': {
    topic: function() {
      return new XingStrategy({
        consumerKey: 'ABC123',
        consumerSecret: 'secret'
      },
      function() {});
    },
    
    'should be named xing': function (strategy) {
      assert.equal(strategy.name, 'xing');
    },
  },
  
  'strategy when loading user profile': {
    topic: function() {
      var strategy = new XingStrategy({
        consumerKey: 'ABC123',
        consumerSecret: 'secret'
      },
      function() {});
      
      // mock
      strategy._oauth.get = function(url, token, tokenSecret, callback) {
        var body = '{ "users": [ {"first_name": "Jared", "id": "_XX0XXX00X", "last_name": "Hanson", "display_name": "<NAME>" } ] }';
        
        callback(null, body, undefined);
      }
      
      return strategy;
    },
    
    'when told to load user profile': {
      topic: function(strategy) {
        var self = this;
        function done(err, profile) {
          self.callback(err, profile);
        }
        
        process.nextTick(function () {
          strategy.userProfile('token', 'token-secret', {}, done);
        });
      },
      
      'should not error' : function(err, req) {
        assert.isNull(err);
      },
      'should load profile' : function(err, profile) {
{'fraction_non_alphanumeric': 0.14922870556673373, 'fraction_numerical': 0.006036217303822937, 'mean_word_length': 2.2353579175704987, 'pattern_counts': {'":': 8, '<': 4, '<?xml version=': 0, '>': 4, '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': '2059966', 'n_tokens_mistral': 904, 'n_tokens_neox': 893, 'n_words': 204}