@@ -74,6 +74,28 @@ describe('alchemy_language', function() {
74
74
var expectedBody = qs . stringify ( { text : payload . text , outputMode : 'json' } ) ;
75
75
assert . equal ( body , expectedBody ) ;
76
76
} ) ;
77
+
78
+ it ( 'should use /text/ endpoint if the text parameter is passed' , function ( ) {
79
+ var req = alchemy . sentiment ( { text : payload . text , url :'www.ibm.com' } , noop ) ;
80
+ var sentimenPath = service . url + '/text/TextGetTextSentiment?apikey=' + service . api_key ;
81
+ assert . equal ( req . uri . href , sentimenPath ) ;
82
+ assert . equal ( req . method , 'POST' ) ;
83
+ assert ( req . form ) ;
84
+ var body = new Buffer ( req . body ) . toString ( 'ascii' ) ;
85
+ var expectedBody = qs . stringify ( { text : payload . text , url :'www.ibm.com' , outputMode : 'json' } ) ;
86
+ assert . equal ( body , expectedBody ) ;
87
+ } ) ;
88
+
89
+ it ( 'should use /html/ endpoint if the html parameter is passed' , function ( ) {
90
+ var req = alchemy . sentiment ( { html : '<html><body>test</body></html>' , url :'www.ibm.com' } , noop ) ;
91
+ var sentimenPath = service . url + '/html/HTMLGetTextSentiment?apikey=' + service . api_key ;
92
+ assert . equal ( req . uri . href , sentimenPath ) ;
93
+ assert . equal ( req . method , 'POST' ) ;
94
+ assert ( req . form ) ;
95
+ var body = new Buffer ( req . body ) . toString ( 'ascii' ) ;
96
+ var expectedBody = qs . stringify ( { html : '<html><body>test</body></html>' , url :'www.ibm.com' , outputMode : 'json' } ) ;
97
+ assert . equal ( body , expectedBody ) ;
98
+ } ) ;
77
99
78
100
} ) ;
79
101
} ) ;
0 commit comments