UNPKG

pomelo

Version:

Pomelo is a fast, scalable game server framework for [node.js](http://nodejs.org). It provides the basic development framework and many related components, including libraries and tools. Pomelo is also suitable for real-time web applications; its distri

46 lines (37 loc) 1.25 kB
var should = require('should'); var serialFilter = require('../../../lib/filters/handler/serial'); var FilterService = require('../../../lib/common/service/filterService'); var util = require('util'); var mockSession = { key : "123" }; var WAIT_TIME = 100; describe("#serialFilter",function(){ it("should do before filter ok",function(done){ var service = new FilterService(); var filter = serialFilter(); service.before(filter); service.beforeFilter(null,mockSession,function(){ should.exist(mockSession); should.exist(mockSession.__serialTask__); done(); }); }); it("should do after filter by doing before filter ok",function(done){ var service = new FilterService(); var filter = serialFilter(); var _session ; service.before(filter); service.beforeFilter(null,mockSession,function(){ should.exist(mockSession); should.exist(mockSession.__serialTask__); _session = mockSession; }); service.after(filter); service.afterFilter(null,null,mockSession,null,function(){ should.exist(mockSession); should.strictEqual(mockSession,_session); }); setTimeout(done,WAIT_TIME); }); });