UNPKG

1.22 kBJavaScriptView Raw
1/***************************************************************************
2 *
3 * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
4 * $Id$
5 *
6 **************************************************************************/
7
8
9
10/**
11 * file.spec.js ~ 2014/02/25 21:35:29
12 * @author leeight(liyubei@baidu.com)
13 * @version $Revision$
14 * @description
15 * 测试一下file handler
16 **/
17var path = require( 'path' );
18
19var base = require( './base' );
20var handler = require( '../lib/handlers/file' );
21
22describe('file', function(){
23 it('default', function(){
24 var context = base.getContext();
25 context.request.pathname = '/index.html';
26
27 spyOn( context, 'start' ).andCallFake( function(){
28 runs(function(){
29 expect( context.start ).toHaveBeenCalled();
30 expect( context.start.callCount ).toBe( 1 );
31 expect( context.content.length ).toBe( 2101 );
32 });
33 } );
34
35 var file = path.join( __dirname, '../lib/handlers/file.js' );
36 handler( file )( context );
37
38 waitsFor(function(){ return context.start.callCount === 1 }, 'x', 1000)
39 });
40});
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64/* vim: set ts=4 sw=4 sts=4 tw=100: */