@@ -884,93 +884,6 @@ test('GH #704: Route with an invalid RegExp params', function(t) {
884
884
} ) ;
885
885
} ) ;
886
886
887
- test ( 'gh-193 basic' , function ( t ) {
888
- SERVER . get (
889
- {
890
- name : 'foo' ,
891
- path : '/foo'
892
- } ,
893
- function ( req , res , next ) {
894
- next ( 'bar' ) ;
895
- }
896
- ) ;
897
-
898
- SERVER . get (
899
- {
900
- name : 'bar' ,
901
- path : '/bar'
902
- } ,
903
- function ( req , res , next ) {
904
- res . send ( 200 ) ;
905
- next ( ) ;
906
- }
907
- ) ;
908
-
909
- CLIENT . get ( '/foo' , function ( err , _ , res ) {
910
- t . ifError ( err ) ;
911
- t . equal ( res . statusCode , 200 ) ;
912
- t . end ( ) ;
913
- } ) ;
914
- } ) ;
915
-
916
- test ( 'gh-193 route name normalization' , function ( t ) {
917
- SERVER . get (
918
- {
919
- name : 'foo' ,
920
- path : '/foo'
921
- } ,
922
- function ( req , res , next ) {
923
- next ( 'b-a-r' ) ;
924
- }
925
- ) ;
926
-
927
- SERVER . get (
928
- {
929
- name : 'b-a-r' ,
930
- path : '/bar'
931
- } ,
932
- function ( req , res , next ) {
933
- res . send ( 200 ) ;
934
- next ( ) ;
935
- }
936
- ) ;
937
-
938
- CLIENT . get ( '/foo' , function ( err , _ , res ) {
939
- t . ifError ( err ) ;
940
- t . equal ( res . statusCode , 200 ) ;
941
- t . end ( ) ;
942
- } ) ;
943
- } ) ;
944
-
945
- test ( 'gh-193 route ENOEXIST' , function ( t ) {
946
- SERVER . get (
947
- {
948
- name : 'foo' ,
949
- path : '/foo'
950
- } ,
951
- function ( req , res , next ) {
952
- next ( 'baz' ) ;
953
- }
954
- ) ;
955
-
956
- SERVER . get (
957
- {
958
- name : 'bar' ,
959
- path : '/bar'
960
- } ,
961
- function ( req , res , next ) {
962
- res . send ( 200 ) ;
963
- next ( ) ;
964
- }
965
- ) ;
966
-
967
- CLIENT . get ( '/foo' , function ( err , _ , res ) {
968
- t . ok ( err ) ;
969
- t . equal ( res . statusCode , 500 ) ;
970
- t . end ( ) ;
971
- } ) ;
972
- } ) ;
973
-
974
887
test ( 'run param only with existing req.params' , function ( t ) {
975
888
var count = 0 ;
976
889
@@ -1023,91 +936,7 @@ test('run param only with existing req.params', function(t) {
1023
936
} ) ;
1024
937
} ) ;
1025
938
1026
- test ( 'gh-193 route only run use once' , function ( t ) {
1027
- var count = 0 ;
1028
-
1029
- SERVER . use ( function ( req , res , next ) {
1030
- count ++ ;
1031
- next ( ) ;
1032
- } ) ;
1033
-
1034
- SERVER . get (
1035
- {
1036
- name : 'foo' ,
1037
- path : '/foo'
1038
- } ,
1039
- function ( req , res , next ) {
1040
- next ( 'bar' ) ;
1041
- }
1042
- ) ;
1043
-
1044
- SERVER . get (
1045
- {
1046
- name : 'bar' ,
1047
- path : '/bar'
1048
- } ,
1049
- function ( req , res , next ) {
1050
- res . send ( 200 ) ;
1051
- next ( ) ;
1052
- }
1053
- ) ;
1054
-
1055
- CLIENT . get ( '/foo' , function ( err , _ , res ) {
1056
- t . ifError ( err ) ;
1057
- t . equal ( res . statusCode , 200 ) ;
1058
- t . equal ( count , 1 ) ;
1059
- t . end ( ) ;
1060
- } ) ;
1061
- } ) ;
1062
-
1063
- test ( 'gh-193 route chained' , function ( t ) {
1064
- var count = 0 ;
1065
-
1066
- SERVER . use ( function addCounter ( req , res , next ) {
1067
- count ++ ;
1068
- next ( ) ;
1069
- } ) ;
1070
-
1071
- SERVER . get (
1072
- {
1073
- name : 'foo' ,
1074
- path : '/foo'
1075
- } ,
1076
- function getFoo ( req , res , next ) {
1077
- next ( 'bar' ) ;
1078
- }
1079
- ) ;
1080
-
1081
- SERVER . get (
1082
- {
1083
- name : 'bar' ,
1084
- path : '/bar'
1085
- } ,
1086
- function getBar ( req , res , next ) {
1087
- next ( 'baz' ) ;
1088
- }
1089
- ) ;
1090
-
1091
- SERVER . get (
1092
- {
1093
- name : 'baz' ,
1094
- path : '/baz'
1095
- } ,
1096
- function getBaz ( req , res , next ) {
1097
- res . send ( 200 ) ;
1098
- next ( ) ;
1099
- }
1100
- ) ;
1101
-
1102
- CLIENT . get ( '/foo' , function ( err , _ , res ) {
1103
- t . ifError ( err ) ;
1104
- t . equal ( res . statusCode , 200 ) ;
1105
- t . equal ( count , 1 ) ;
1106
- t . end ( ) ;
1107
- } ) ;
1108
- } ) ;
1109
-
1110
- test ( 'gh-193 route params basic' , function ( t ) {
939
+ test ( 'next("string") returns InternalServer' , function ( t ) {
1111
940
var count = 0 ;
1112
941
1113
942
SERVER . use ( function ( req , res , next ) {
@@ -1126,27 +955,15 @@ test('gh-193 route params basic', function(t) {
1126
955
}
1127
956
) ;
1128
957
1129
- SERVER . get (
1130
- {
1131
- name : 'bar' ,
1132
- path : '/bar/:baz'
1133
- } ,
1134
- function ( req , res , next ) {
1135
- t . notOk ( req . params . baz ) ;
1136
- res . send ( 200 ) ;
1137
- next ( ) ;
1138
- }
1139
- ) ;
1140
-
1141
958
CLIENT . get ( '/foo/blah' , function ( err , _ , res ) {
1142
- t . ifError ( err ) ;
1143
- t . equal ( res . statusCode , 200 ) ;
959
+ t . ok ( err ) ;
960
+ t . equal ( res . statusCode , 500 ) ;
1144
961
t . equal ( count , 1 ) ;
1145
962
t . end ( ) ;
1146
963
} ) ;
1147
964
} ) ;
1148
965
1149
- test ( 'gh-193 next("route ") from a use plugin' , function ( t ) {
966
+ test ( 'next("string ") from a use plugin returns InternalServer ' , function ( t ) {
1150
967
var count = 0 ;
1151
968
1152
969
SERVER . use ( function plugin ( req , res , next ) {
@@ -1160,25 +977,14 @@ test('gh-193 next("route") from a use plugin', function(t) {
1160
977
path : '/foo'
1161
978
} ,
1162
979
function getFoo ( req , res , next ) {
1163
- res . send ( 500 ) ;
1164
- next ( ) ;
1165
- }
1166
- ) ;
1167
-
1168
- SERVER . get (
1169
- {
1170
- name : 'bar' ,
1171
- path : '/bar'
1172
- } ,
1173
- function getBar ( req , res , next ) {
1174
980
res . send ( 200 ) ;
1175
981
next ( ) ;
1176
982
}
1177
983
) ;
1178
984
1179
985
CLIENT . get ( '/foo' , function ( err , _ , res ) {
1180
- t . ifError ( err ) ;
1181
- t . equal ( res . statusCode , 200 ) ;
986
+ t . ok ( err ) ;
987
+ t . equal ( res . statusCode , 500 ) ;
1182
988
t . equal ( count , 1 ) ;
1183
989
t . end ( ) ;
1184
990
} ) ;
@@ -3000,14 +2806,11 @@ test('async handler without next', function(t) {
3000
2806
} ) ;
3001
2807
} ) ;
3002
2808
3003
- test ( 'async handler resolved with string should re-route ' , function ( t ) {
2809
+ test ( 'async handler should discard value ' , function ( t ) {
3004
2810
SERVER . get ( '/hello/:name' , async function tester ( req , res ) {
3005
2811
await helper . sleep ( 10 ) ;
3006
- return 'getredirected' ;
3007
- } ) ;
3008
-
3009
- SERVER . get ( '/redirected' , async function tester ( req , res ) {
3010
2812
res . send ( req . params . name ) ;
2813
+ return 'foo' ;
3011
2814
} ) ;
3012
2815
3013
2816
CLIENT . get ( '/hello/mark' , function ( err , _ , res ) {
0 commit comments