<commit_before><commit_msg>test(mkdir): create dir in temp<commit_after>'use strict';
var assert = require('power-assert');
var shouldRejected = require('promise-test-helper').shouldRejected;
var shouldFulfilled = require('promise-test-helper').shouldFulfilled;
var mkdirInTemp = require('../lib/mkdir-in-temp');
var errors = require('common-errors');
var path = require('path');

describe('mkdir in temp', function () {
  it('should be rejected, value is required', function () {
    return shouldRejected(mkdirInTemp()).catch(function (error) {
      assert(error instanceof errors.ArgumentError);
    });
  });

  it('should be rejected, dir is required', function () {
    var params = { dir: null };
    return shouldRejected(mkdirInTemp(params)).catch(function (error) {
      assert(error instanceof errors.ArgumentNullError);
    });
  });
  it('should be rejected, dir has .. directory', function () {
    var params = { dir: '../baz' };
    return shouldRejected(mkdirInTemp(params)).catch(function (error) {
      assert(error instanceof errors.ArgumentError);
    });
  });
  it('should be fulfilled', function () {
    var params = { dir: 'foo/bar' };
    var sliced = path.sep + 'foo' + path.sep + 'bar';
    return shouldFulfilled(mkdirInTemp(params)).then(function (value) {
      value['clearMethod']();
      assert.equal(value['path'].slice(-8), sliced);
    });
  });
  it('should be fulfilled, included ..', function () {
    var params = { dir: 'foo/../bar' };
    var sliced = path.sep + 'bar';
    return shouldFulfilled(mkdirInTemp(params)).then(function (value) {
      value['clearMethod']();
      assert.equal(value['path'].slice(-4), sliced);
    });
  });
});
{'fraction_non_alphanumeric': 0.17337278106508874, 'fraction_numerical': 0.001183431952662722, 'mean_word_length': 3.9882005899705013, 'pattern_counts': {'":': 0, '<': 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': '634512', 'n_tokens_mistral': 513, 'n_tokens_neox': 492, 'n_words': 114}