<commit_before>expect  = require 'expect.js'
nock    = require 'nock'

LayerVault = require '../../lib/layervault'

describe 'Project', ->
  before ->
    @config = new LayerVault.Configuration ->
      @accessToken = 'foobar'

    @client = new LayerVault.Client(@config)
    @organization = @client.organization('ryan-lefevre')

  describe 'get', ->
    beforeEach ->
      @project = @organization.project('Test Project')
      nock(@config.apiBase)
        .get("#{@config.apiPath}#{@project.nodePath}")
        .reply(200, require('../fixtures/project/get'))

    it 'does not error', (done) ->
      @project.get (err, resp) ->
        expect(err).to.be(null)
        done()

    it 'returns a response object', (done) ->
      @project.get (err, resp) ->
        expect(resp).to.be.an('object')
        expect(resp.name).to.be('Test Project')
        expect(resp.files.length).to.be(1)
        done()

    it 'applies the data to the project object', (done) ->
      project = @project
      @project.get (err, resp) ->
        expect(@name).to.be('Test Project')
        expect(@member).to.be(false)
        done()

    it 'correctly initializes relations', (done) ->
      @project.get (err, resp) ->
        expect(@files[0]).to.have.property('nodePath')
        expect(@files[0].get).to.be.a('function')
        done()

  describe 'create', ->
    beforeEach ->
      @project = @organization.project('Test Project')
      nock(@config.apiBase)
        .post("#{@config.apiPath}#{@project.nodePath}")
        .reply(200, require('../fixtures/project/create'))

    it 'does not error', (done) ->
      @project.create (err, resp) ->
        expect(err).to.be(null)
        done()

    it 'returns a response object', (done) ->
      @project.create (err, resp) ->
        expect(resp).to.not.be(null)
        expect(resp).to.be.an('object')
        done()

    it 'applies the data to the project object', (done) ->
      @project.create (err, resp) ->
        expect(@name).to.be('Test Project')
        done()

    <commit_msg>Project deletion tests<commit_after>expect  = require 'expect.js'
nock    = require 'nock'

LayerVault = require '../../lib/layervault'

describe 'Project', ->
  before ->
    @config = new LayerVault.Configuration ->
      @accessToken = 'foobar'

    @client = new LayerVault.Client(@config)
    @organization = @client.organization('ryan-lefevre')

  describe 'get', ->
    beforeEach ->
      @project = @organization.project('Test Project')
      nock(@config.apiBase)
        .get("#{@config.apiPath}#{@project.nodePath}")
        .reply(200, require('../fixtures/project/get'))

    it 'does not error', (done) ->
      @project.get (err, resp) ->
        expect(err).to.be(null)
        done()

    it 'returns a response object', (done) ->
      @project.get (err, resp) ->
        expect(resp).to.be.an('object')
        expect(resp.name).to.be('Test Project')
        expect(resp.files.length).to.be(1)
        done()

    it 'applies the data to the project object', (done) ->
      project = @project
      @project.get (err, resp) ->
        expect(@name).to.be('<NAME>')
        expect(@member).to.be(false)
        done()

    it 'correctly initializes relations', (done) ->
      @project.get (err, resp) ->
        expect(@files[0]).to.have.property('nodePath')
        expect(@files[0].get).to.be.a('function')
        done()

  describe 'create', ->
    beforeEach ->
      @project = @organization.project('Test Project')
      nock(@config.apiBase)
        .post("#{@config.apiPath}#{@project.nodePath}")
        .reply(200, require('../fixtures/project/create'))

    it 'does not error', (done) ->
      @project.create (err, resp) ->
        expect(err).to.be(null)
        done()

    it 'returns a response object', (done) ->
      @project.create (err, resp) ->
        expect(resp).to.not.be(null)
        expect(resp).to.be.an('object')
        done()

    it 'applies the data to the project object', (done) ->
      @project.create (err, resp) ->
        expect(@name).to.be('Test Project')
        done()

  describe 'delete', ->
    beforeEach ->
      nock(@config.apiBase)
        .delete("#{@config.apiPath}#{@project.nodePath}")
        .reply(200, require('../fixtures/project/delete'))

    it 'does not error', (done) ->
      @project.delete (err, resp) ->
        expect(err).to.be(null)
        done()

    it 'returns success', (done) ->
      @project.delete (err, resp) ->
        expect(resp).to.not.be(null)
        expect(resp.error).to.be('success')
        done()

{'fraction_non_alphanumeric': 0.1802019315188762, 'fraction_numerical': 0.0046093064091308165, 'mean_word_length': 2.4083769633507854, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 52, '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': '5254880', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1434, 'n_words': 292}