/* global describe, it, xit */
/* jslint node: true, esnext: true */

"use strict";

const chai = require('chai'),
  expect = chai.expect,
  should = chai.should();

import assert from 'assert';
import {
  init
}
from '../lib/svn';

var credentials = {
  password: 'xxx',
  user: 'yyy'
};

if (process.env.SVN_USER) {
  credentials.user = process.env.SVN_USER;
}

if (process.env.SVN_PASSWORD) {
  credentials.password = process.env.SVN_PASSWORD;
}

describe('initialize', function () {
  it('has toString', function (done) {
    init('https://subversion.assembla.com/svn/delivery_notes', {
      credentials: credentials
    }).then(function (svn) {
      assert.equal(`${svn}`, "svn");
      done();
    }, done);
  });

  if (process.env.SVN_USER) {
    it('has davFeatures', function (done) {
      init('https://subversion.assembla.com/svn/delivery_notes/', {
        credentials: credentials
      }).then(function (svn) {
        assert.equal(svn.davFeatures.has('1'), true);
        assert.equal(svn.davFeatures.has('2'), true);
        assert.equal(svn.davFeatures.has('baseline'), true);
        assert.equal(svn.davFeatures.has('version-control'), true);
        assert.equal(svn.davFeatures.has('checkout'), true);
        assert.equal(svn.davFeatures.has('working-resource'), true);
        assert.equal(svn.davFeatures.has('merge'), true);
        assert.equal(svn.davFeatures.has('version-controlled-collection'), true);
        assert.equal(svn.davFeatures.has('http://subversion.tigris.org/xmlns/dav/svn/mergeinfo'), true);
        done();
      }, done);
    });

    it('has allowedMethods', function (done) {
      init('https://subversion.assembla.com/svn/delivery_notes/', {
        credentials: credentials
      }).then(function (svn) {
        assert.equal(svn.allowedMethods.has('GET'), true);
        assert.equal(svn.allowedMethods.has('OPTIONS'), true);
        done();
      }, done);
    });
  }

  it('has basicAuthorization', function (done) {
    init('https://subversion.assembla.com/svn/delivery_notes/', {
      credentials: credentials
    }).then(function (svn) {
      try {
        if (process.env.SVN_USER) {
          assert.equal(svn.basicAuthorization.substring(0, 6), "Basic ");
        } else {
          assert.equal(svn.basicAuthorization, "Basic eXl5Onh4eA==");
        }
        done();
      } catch (e) {
        done(e);
      }
    }, done);
  });
});

@@ -470,21 +470,17 @@
 e', 
-function () %7B
+() =%3E %7B%0A%0A
 %0A  i
@@ -497,33 +497,21 @@
 tring', 
-function (done) %7B
+() =%3E
 %0A    ini
@@ -611,38 +611,22 @@
 %7D).then(
-function (svn) %7B%0A     
+svn =%3E
  assert.
@@ -651,41 +651,12 @@
 vn%22)
-;%0A      done();%0A    %7D, done);%0A  %7D
+)%0A  
 );%0A%0A
@@ -711,33 +711,21 @@
 tures', 
-function (done) %7B
+() =%3E
 %0A      i
@@ -828,38 +828,30 @@
     %7D).then(
-function (svn)
+svn =%3E
  %7B%0A        a
@@ -1463,39 +1463,15 @@
     
-  done();%0A      %7D, done);
+%7D)
 %0A    
-%7D
 );%0A%0A
@@ -1499,33 +1499,21 @@
 thods', 
-function (done) %7B
+() =%3E
 %0A      i
@@ -1616,38 +1616,30 @@
     %7D).then(
-function (svn)
+svn =%3E
  %7B%0A        a
@@ -1761,39 +1761,15 @@
     
-  done();%0A      %7D, done);
+%7D)
 %0A    
-%7D
 );%0A 
@@ -1807,25 +1807,13 @@
 n', 
-function (done) %7B
+() =%3E
 %0A   
@@ -1922,39 +1922,17 @@
 hen(
-function (svn) %7B%0A      try
+svn =%3E
  %7B%0A
-  
     
@@ -1961,34 +1961,32 @@
 USER) %7B%0A        
-  
 assert.equal(svn
@@ -2029,26 +2029,24 @@
  %22Basic %22);%0A
-  
       %7D else
@@ -2052,26 +2052,24 @@
 e %7B%0A        
-  
 assert.equal
@@ -2126,90 +2126,19 @@
     
- 
- 
 %7D%0A    
-    done();%0A      %7D catch (e) %7B%0A        done(e);%0A      %7D%0A    %7D, done);%0A  %7D
+%7D)%0A  
 );%0A%7D

use arrow functions