2 * Copyright 2014 IBM Corp.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 var should = require("should");
18 var sinon = require("sinon");
19 var fs = require("fs");
20 var request = require("request");
22 var apiRequest = require("../../../../red/cli/lib/request");
23 var config = require("../../../../red/cli/lib/config");
25 describe("cli request", function() {
26 var sandbox = sinon.sandbox.create();
28 sandbox.stub(fs,"readFileSync",function() {
29 return '{"target":"http://example.com:1880"}'
36 it('returns the json response to a get', sinon.test(function(done) {
37 this.stub(request, 'get').yields(null, {statusCode:200}, JSON.stringify({a: "b"}));
39 apiRequest("/foo",{}).then(function(res) {
40 res.should.eql({a:"b"});
42 }).otherwise(function(err) {