Пример #1
0
 .then( res => {
     test.object( res.body ).hasProperty( "message" );
     test.string( res.body.message ).is( "Please specify the new name of the file" );
     test.bool( res.body.error ).isTrue();
     done();
 } ).catch( err => done( err ) );
	it( 'passes with string', function() {
		test.bool( Validation.validateStringParameter( 'a' ) ).isTrue();
	});
	it( 'fails with undefined', function() {
		test.bool( Validation.validateStringParameter( undefined ) ).isFalse();
	});
	it( 'fails if number is NaN', function() {
		test.bool( Validation.validateIntegerParameter( NaN ) ).isFalse();
	});
	it( 'passes with false', function() {
		test.bool( Validation.validateBooleanParameter( false ) ).isTrue();
	});
	it( 'passes on a moment date parse and unix time of a valid ISO8601 string', function() {
		var time = moment( "1984-01-02T03:04:05Z", moment.ISO_8601 ).unix();
		test.bool( Validation.validateNumberParameter(time) ).isTrue();
	});
	it( 'passes with an integer', function() {
		test.bool( Validation.validateIntegerParameter( 7 ) ).isTrue();
	});
Пример #8
0
 api.resolve(spec, 'http://localhost:8000/swagger.json', function (spec, unresolved) {
   expect(spec.paths['/users'].get.parameters.length).toBe(2);
   expect(Object.keys(unresolved).length).toBe(0);
   test.object(spec.paths['/health'].get);
   done();
 });
Пример #9
0
 api.resolve(spec, 'http://localhost:8000/v2/petstore.json', function (spec, unresolved) {
   expect(Object.keys(unresolved).length).toBe(0);
   test.object(spec);
   done();
 });
Пример #10
0
 api.resolve(spec, 'http://localhost:8000/foo/bar/swagger.json', function (spec) {
   var health = spec.paths['/health'];
   test.object(health);
   done();
 });
Пример #11
0
 api.resolve(spec, 'http://localhost:8000/foo/bar/swagger.json', function (spec, unresolved) {
   expect(unresolved.Category).toExist();
   var health = spec.paths['/health'];
   test.object(health);
   done();
 });
Пример #12
0
 api.resolve(spec, 'http://localhost:8000/v2/petstore.json', function (spec) {
   var path = spec.paths['/myUsername'];
   test.object(path);
   test.object(path.get);
   done();
 });
Пример #13
0
 .then( ( res ) => {
     test.string( res.body.data[0].name ).is( "testy" );
     test.bool( res.body.error ).isNotTrue();
     done();
 } ).catch( err => done( err ) );
Пример #14
0
 .then( res => {
     test.object( res.body ).hasProperty( "message" );
     test.string( res.body.message ).is( "Renamed file to 'testy'" );
     test.bool( res.body.error ).isNotTrue();
     done();
 } ).catch( err => done( err ) );
	it( 'fails if number is less than min', function() {
		test.bool( Validation.validateNumberParameter( 7, 8, 9 ) ).isFalse();
	});
Пример #16
0
 .then( res => {
     test.bool( res.body.error ).isTrue();
     test.object( res.body ).hasProperty( "message" );
     test.string( res.body.message ).is( "You don't have permission to make this request" );
     done();
 } ).catch( err => done( err ) );
	it( 'fails if number is more than max', function() {
		test.bool( Validation.validateNumberParameter( 7, 5, 6 ) ).isFalse();
	});
Пример #18
0
 .then( res => {
     test.bool( res.body.error ).isNotTrue();
     done();
 } ).catch( err => done( err ) );
	it( 'fails on a moment date parse and unix time of an invalid ISO8601 string', function() {
		var time = moment( "03:04:05PM Jan 2nd 1984 UST", moment.ISO_8601 ).unix();
		test.bool( Validation.validateNumberParameter(time) ).isFalse();
	});
Пример #20
0
'use strict';

const url = require('url');
const unitjs = require('unit.js');
const fs = require('fs');

const assert = unitjs.assert;
const fsPromise = unitjs.promisifyAll(fs);

const EveCentralClient = require('../lib/evecentral');

function parseClient(fileName, done) {
  const client = new EveCentralClient();
  let xmlData = null;

  fsPromise.readFileAsync(__dirname + '/' + fileName + '.xml', 'utf-8')
    .then(client.parse)
    .then((data) => {
      xmlData = data;
      return fsPromise.readFileAsync(__dirname + '/' + fileName + '.json', 'utf-8');
    })
    .then((data) => {
      assert.deepEqual(xmlData, JSON.parse(data));
    })
    .catch(assert.ifError)
    .finally(done)
    .done();
};


describe('evejsapi.EveCentralClient', () => {
	it( 'fails if type is not number', function() {
		test.bool( Validation.validateIntegerParameter( "7" ) ).isFalse();
	});
Пример #22
0
 it('should be of correct type', function() {
     test.object(r).isInstanceOf(qdb.Range);
 });
	it( 'fails if number is negative floating point', function() {
		test.bool( Validation.validateIntegerParameter( -1.1 ) ).isFalse();
	});
Пример #24
0
 it("shouldn't have an 'alias' property", function() {
     test.object(r).hasNotProperty('alias');
 });
	it( 'fails with a string', function() {
		test.bool( Validation.validateBooleanParameter( 'a' ) ).isFalse();
	});
Пример #26
0
 it("should have a 'blobScanRegex()' method", function() {
     test.object(r).hasProperty('blobScanRegex');
     test.must(r.blobScanRegex).be.a.function();
 });
	it( 'fails with null', function() {
		test.bool( Validation.validateStringParameter( null ) ).isFalse();
	});
Пример #28
0
exports.updateUser = function(req, res){
	console.log("----------------------------");
	
	var receiveTime = Date.now();
    
    var diffStartTime = req.body.diffStartTime;
    var diffEndTime = req.body.diffEndTime;
    var sendTime = req.body.sendTime;   
    var delta = req.body.delta;
	var rate = req.body.rate;
    console.log(rate);
  	var patchStartTime ;          
    var patchEndTime ;
 
    patchStartTime = Date.now();

    switch (algorithm) {
    	case "0":
    	    comparedData = delta;
    		break;
    	case "1":
	    	jsondiffpatch.patch(comparedData, delta);
    		break;
        case "2":
            jsonpatch.apply(comparedData, delta);
            break;
        case "3":
            comparedData = jiff.patch(delta, comparedData);
            break;
        case "4":
            comparedData = changeSet.apply(delta, comparedData);
            break;
        case "5":
            comparedData = diffjson.applyChanges(comparedData, delta);
            break;
    }

	patchEndTime = Date.now();
    
    //assert the data is the same
    var flag = false;
    console.log(JSON.stringify(users[1]).length);
    console.log(JSON.stringify(comparedData).length);
    var err = test.error(function() {
        //assert the data
   	    assert.equal(JSON.stringify(comparedData), JSON.stringify(users[1]));
   	    //set the flag
        flag = true;
   	    throw new Error('OK!');
    });
    
    if(flag) {
    	//the two data is the same
        writeCSV();
        res.send("ok");
    } else {
    	//the two data is not the same
        res.send("ko");
    }

    function writeCSV () {

        var totalTime = (diffEndTime - diffStartTime) + (receiveTime - sendTime) + (patchEndTime - patchStartTime);

        var result = (diffEndTime - diffStartTime)+',' +(receiveTime - sendTime) +',' +(patchEndTime - patchStartTime)+ ','+totalTime+','+rate+ '\n';

        fs.writeFile('./result/'+size+'-P'+probability+'-A'+algorithm+'.csv', result, {flag: 'a'}, function(err){
            if(err) throw err;
            console.log("success");
        });

    }

}
	it( 'fails with a number', function() {
		test.bool( Validation.validateStringParameter( 1 ) ).isFalse();
	});	
Пример #30
0
 .then( res => {
     test.object( res.body ).hasProperty( "message" );
     test.string( res.body.message ).is( "File '123' does not exist" );
     test.bool( res.body.error ).isTrue();
     done();
 } ).catch( err => done( err ) );