<commit_before>const chai = require('chai');
const chaiHttp = require('chai-http');
const mongoose = require('mongoose');

const app = require('../../lib/app');

const assert = chai.assert;

chai.use(chaiHttp);

// connect to mongodb
process.env.DB_URI = 'mongodb://localhost:27017/assets-REST';
require('../../lib/connection');

describe('assets REST API', () => {

    before(() => mongoose.connection.dropDatabase());
    const request = chai.request(app);

    // test data
    let testAsset0 = {
        type: 'House',
        model: 'Victorian',
        purchase_price: 600000
    };
    let testAsset1 = {
        type: 'Vehicle',
        model: 'Moped',
        purchase_price: 1000
    };

    function saveAsset (asset) {
        return request.post('/assets')
            .send(asset)
            .then(res => res.body);
    }

    it('returns a list of assets', () => {
        return Promise.all([
        // Save test assets
            saveAsset(testAsset0),
            saveAsset(testAsset1)
        ])
        .then(savedAssets => {
            testAsset0 = savedAssets[0];
            testAsset1 = savedAssets[1];
        })
        // Test to see if GET all gets all previously saved assets
        .then(() => request.get('/assets'))
        .then(res => { 
            const assets = res.body;
            assert.deepEqual(assets, [testAsset0, testAsset1]);
        });<commit_msg>fixed asset test<commit_after>const chai = require('chai');
const chaiHttp = require('chai-http');
const mongoose = require('mongoose');

const app = require('../../lib/app');

const assert = chai.assert;

chai.use(chaiHttp);

// connect to mongodb
process.env.DB_URI = 'mongodb://localhost:27017/assets-REST';
require('../../lib/connection');

describe('assets REST API', () => {

    before(() => mongoose.connection.dropDatabase());
    const request = chai.request(app);

    // test data
    let testAsset0 = {
        asset_type: 'House',
        model: 'Victorian',
        purchase_price: 600000
    };
    let testAsset1 = {
        asset_type: 'Vehicle',
        model: 'Moped',
        purchase_price: 1000
    };

    function saveAsset (asset) {
        return request.post('/assets')
            .send(asset)
            .then(res => res.body);
    }

    it('returns a list of assets', () => {
        return Promise.all([
        // Save test assets
            saveAsset(testAsset0),
            saveAsset(testAsset1)
        ])
        .then(savedAssets => {
            testAsset0 = savedAssets[0];
            testAsset1 = savedAssets[1];
        })
        // Test to see if GET all gets all previously saved assets
        .then(() => request.get('/assets'))
        .then(res => { 
            const assets = res.body;
            console.log('assets', assets);
            console.log('testAsset0', testAsset0);
            console.log('testAsset1', testAsset1);

            assert.deepEqual(assets, [testAsset0, testAsset1]);
        });
{'fraction_non_alphanumeric': 0.1494097807757167, 'fraction_numerical': 0.01821247892074199, 'mean_word_length': 2.1188222923238698, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '6409632', 'n_tokens_mistral': 908, 'n_tokens_neox': 868, 'n_words': 194}