it('should be able to check if the incoming request contains the `Content-Type` header field, and it contains the give mime `type`', function(done) {

        var request = new MockExpressRequest();

        expect(request.is('html')).to.be.false;
        expect(request.is('json')).to.be.equal('json');
        expect(request.is('application/json')).to.be.equal('application/json');

        done();

    });
Example #2
0
	it('should create UserTestEntity', function () {
		var entity = gleam.entity('user/test');
		expect(entity).to.be.an('object');
		expect(entity).to.have.keys('id');
		expect(entity.id).to.be.a('function');
		expect(Gleam.is(entity, 'user/test')).to.be.true;
	});
Example #3
0
	it('should create UserEntity', function () {
		var entity = gleam.entity('user');
		expect(entity).to.be.an('object');
		expect(entity).to.have.keys('id', 'name', 'email');
		expect(entity.id).to.be.a('function');
		expect(entity.name).to.be.a('function');
		expect(entity.email).to.be.a('function');
		expect(Gleam.is(entity, 'user')).to.be.true;
	});
      group[0].forEach(function(obj) {
        var true_type = group[1];
        Assert(Type(obj, true_type), "testing " + obj + ' is ' + true_type);
        Assert(Type.is(obj, true_type), "testing " + obj + ' is ' + true_type);

        types.forEach(function(false_type) {
          if (group[1] !== false_type) {
            Assert.strictEqual(Type(obj, false_type), false, "testing " + obj + ' is ' + false_type);
            Assert.strictEqual(Type.is(obj, false_type), false, "testing " + obj + ' is ' + false_type);
          }
        });
      });
Example #5
0
0===l.length&&0===m?e=!0:b={type:"splice",object:j.object,index:Math.min(j.index,b.index),removed:l,addedCount:m},h-=j.addedCount-j.removed.length}else if(b.index<j.index){var n=b.addedCount-b.removed.length;j.index+=n,h+=n,g.splice(i++,0,b),e=!0}}e||g.push(b)}),g.length>0&&b(g)}return a("object-observe-api")?function(a,b){return Array.observe(a,b=e.bind(a,b)),{deliver:Object.deliverChangeRecords.bind(Object,b),remove:Array.unobserve.bind(Array,a,b)}}:function(a,c){var d=Object.create(b.observe(a,c=e.bind(a,c),["add","update","delete","splice"]));return d.deliver=b.deliverChangeRecords.bind(b,c),d}}(),c}),define("decor/Observable",["./features","./features!object-observe-api?:./schedule"],function(a,b){"use strict";var c,d=Object.defineProperty,e=Object.getOwnPropertyDescriptor,f={add:1,update:1,"delete":1,reconfigure:1,setPrototype:1,preventExtensions:1};if(c=function(a){this._observable||d(this,"_observable",{value:1}),a&&c.assign(this,a)},c.test=function(a){return a&&a._observable},c.is=a("object-is-api")?Object.is:function(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b},c.assign=function(a){if(null==a)throw new TypeError("Can't convert "+a+" to object.");a=Object(a);for(var b=1,d=arguments.length;d>b;++b)for(var e=Object(arguments[b]),f=Object.getOwnPropertyNames(e),g=0,h=f.length;h>g;++g){var i=f[g];c.prototype.set.call(a,i,e[i])}return a},a("object-observe-api")?c.canObserve=function(a){return"object"==typeof a&&null!=a}:c.canObserve=c.test,a("object-observe-api"))d(c.prototype,"set",{value:function(a,b){return this[a]=b,b},configurable:!0,writable:!0}),c.observe=function(a,b,c){return Object.observe.call(this,a,b,c),{remove:function(){Object.unobserve(a,b)}}},c.getNotifier=Object.getNotifier,c.deliverChangeRecords=Object.deliverChangeRecords;else{d(c.prototype,"set",{value:function(a,b){var d=a in this?"update":"add",f=this[a],g=(e(this,a)||{}).set;if(this[a]=b,!c.is(b,f)&&void 0===g){var h={type:d,object:this,name:a+""};"update"===d&&(h.oldValue=f),c.getNotifier(this).notify(h)}return b},configurable:!0,writable:!0});var g=0,h={},i=null,j=function(){a("polymer-platform")&&Platform.performMicrotaskCheckpoint();for(var b=!0;b;){b=!1;var d=[];for(var e in h)d.push(h[e]);h={},d=d.sort(function(a,b){return a._seq-b._seq});for(var f=0,g=d.length;g>f;++f)d[f]._changeRecords.length>0&&(c.deliverChangeRecords(d[f]),b=!0)}i=null},k=function(a){0===a._changeRecords.length&&0===a._refCountOfNotifier&&(a._seq=void 0)},l=function(a){this.target=a,this.observers={},this._activeChanges={}};l.prototype={notify:function(a){function c(a,b,c){if(c in b){for(var d in b)if(a[d]>0)return!1;return!0}}for(var d in this.observers)if(c(this._activeChanges,this.observers[d].acceptTable,a.type)){var e=this.observers[d].callback;e._changeRecords.push(a),h[e._seq]=e,i||(i=b(j))}},performChange:function(a,b){this._activeChanges[a]=(this._activeChanges[a]||0)+1;var c=b.call(void 0);if(--this._activeChanges[a],c){var d={type:a,object:this.target};for(var e in c)e in d||(d[e]=c[e]);this.notify(d)}}},c.getNotifier=function(a){return e(a,"_notifier")||d(a,"_notifier",{value:new l(a)}),a._notifier},c.observe=function(a,b,d){if(Object(a)!==a)throw new TypeError("Observable.observe() cannot be called on non-object.");"_seq"in b||(b._seq=g++,b._changeRecords=[],b._refCountOfNotifier=0);var e=d?d.reduce(function(a,b){return a[b]=1,a},{}):f,h=c.getNotifier(a);return b._seq in h.observers?h.observers[b._seq].acceptTable=e:(h.observers[b._seq]={acceptTable:e,callback:b},++b._refCountOfNotifier),{remove:function(){b._seq in h.observers&&(delete h.observers[b._seq],--b._refCountOfNotifier)}}},c.deliverChangeRecords=function(b){var c=b._changeRecords.length;try{b(b._changeRecords.splice(0,c))}catch(d){a("console-api")&&console.error("Error occured in observer callback: "+(d.stack||d))}k(b)}}return c}),define("decor/Invalidating",["dcl/dcl","./Stateful","./Destroyable"],function(a,b,c){var d=a([b,c],{constructor:a.after(function(){this.initializeInvalidating()}),initializeInvalidating:function(){this._hComputing||this._hRendering||(this.own(this._hComputing=this.observe(function(a){this.computeProperties(a),this.deliverComputing()})),this.computeProperties(this,!0),this.initializeRendering(this),this.refreshRendering(this,!0),this.own(this._hRendering=this.observe(function(a){var b=this.shouldInitializeRendering(a);b?(this.initializeRendering(a),this.refreshRendering(this,!0)):this.refreshRendering(a)})))},deliverComputing:function(){return this._hComputing&&this._hComputing.deliver(),this._hComputing},discardComputing:function(){return this._hComputing&&this._hComputing.discardChanges(),this._hComputing},shouldInitializeRendering:function(){},computeProperties:function(){},initializeRendering:function(){},refreshRendering:function(){}});return a.chainAfter(d,"computeProperties"),a.chainAfter(d,"refreshRendering"),d}),define("decor/Evented",["dcl/dcl","dcl/advise"],function(a,b){return a(null,{on:function(a,c){return b.before(this,"on"+a,c)},emit:function(a){var b="on"+a;if(this[b]){var c=Array.prototype.slice.call(arguments,1);this[b].apply(this,c)}}})}),define("decor/Destroyable",["dcl/advise","dcl/dcl"],function(a,b){var c=b(null,{destroy:b.advise({before:function(){this._beingDestroyed=!0,this._releaseHandles()},after:function(){this._destroyed=!0}}),_releaseHandles:function(){},own:function(){var b=["destroy","remove","cancel"],c=Array.prototype.slice.call(arguments);return c.forEach(function(c){function d(){f.destroy(),g.forEach(function(a){a.destroy()})}var e,f=a.after(this,"_releaseHandles",function(){c[e]()}),g=[];c.then&&c.then(d,d),b.forEach(function(b){"function"==typeof c[b]&&(e||(e=b),c.then||g.push(a.after(c,b,d)))})},this),c},defer:function(a,b){var c=setTimeout(function(){c&&(c=null,this._destroyed||a.call(this))}.bind(this),b||0);return{remove:function(){return c&&(clearTimeout(c),c=null),null}}}});return b.chainBefore(c,"destroy"),c});
 types.forEach(function(false_type) {
   if (group[1] !== false_type) {
     Assert.strictEqual(Type(obj, false_type), false, "testing " + obj + ' is ' + false_type);
     Assert.strictEqual(Type.is(obj, false_type), false, "testing " + obj + ' is ' + false_type);
   }
 });