1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 20:52:22 +00:00
2018-07-08 17:52:33 +08:00

44 lines
1.1 KiB
JavaScript
Executable File

'use strict';
var SwaggerClient = require('swagger-client');
describe('EchoService', function() {
var client;
beforeEach(function(done) {
new SwaggerClient({
url: "http://localhost:8080/swagger/echo_service.swagger.json",
usePromise: true,
}).then(function(c) {
client = c;
done();
});
});
describe('Echo', function() {
it('should echo the request back', function(done) {
client.EchoService.Echo(
{id: "foo"},
{responseContentType: "application/json"}
).then(function(resp) {
expect(resp.obj).toEqual({id: "foo"});
}).catch(function(err) {
done.fail(err);
}).then(done);
});
});
describe('EchoBody', function() {
it('should echo the request back', function(done) {
client.EchoService.EchoBody(
{body: {id: "foo"}},
{responseContentType: "application/json"}
).then(function(resp) {
expect(resp.obj).toEqual({id: "foo"});
}).catch(function(err) {
done.fail(err);
}).then(done);
});
});
});