github.com/grpc-ecosystem/grpc-gateway/v2@v2.19.1/examples/internal/browser/echo_service.spec.js (about)

     1  'use strict';
     2  
     3  var SwaggerClient = require('swagger-client');
     4  
     5  describe('EchoService', function () {
     6    var client;
     7  
     8    beforeEach(function (done) {
     9      new SwaggerClient({
    10        url: "http://localhost:8080/openapiv2/echo_service.swagger.json",
    11        usePromise: true,
    12      }).then(function (c) {
    13        client = c;
    14        done();
    15      });
    16    });
    17  
    18    describe('Echo', function () {
    19      it('should echo the request back', function (done) {
    20        var expected = {
    21          id: "foo",
    22          num: "0",
    23          status: null
    24        };
    25        client.EchoService.EchoService_Echo(
    26          expected,
    27          { responseContentType: "application/json" }
    28        ).then(function (resp) {
    29          expect(resp.obj).toEqual(expected);
    30        }).catch(function (err) {
    31          done.fail(err);
    32        }).then(done);
    33      });
    34    });
    35  
    36    describe('EchoBody', function () {
    37      it('should echo the request back', function (done) {
    38        var expected = {
    39          id: "foo",
    40          num: "0",
    41          status: null
    42        };
    43        client.EchoService.EchoService_EchoBody(
    44          { body: expected },
    45          { responseContentType: "application/json" }
    46        ).then(function (resp) {
    47          expect(resp.obj).toEqual(expected);
    48        }).catch(function (err) {
    49          done.fail(err);
    50        }).then(done);
    51      });
    52    });
    53  });