Skip to content

Commit

Permalink
Fixup browser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Aug 15, 2023
1 parent 0a25bf4 commit 1ebc4da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export * from './index';
export * as StellarBase from 'stellar-base';
export * as SorobanClient from './soroban';

import axios from 'axios'; // idk why axios is weird
export { axios };
Expand Down
24 changes: 12 additions & 12 deletions test/integration/client_headers_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const http = require("http");
const url = require("url");
const http = require('http');
const url = require('url');
const port = 3100;

const versionPattern = /^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9])?)?$/;

describe("integration tests: client headers", function (done) {
if (typeof window !== "undefined") {
describe('integration tests: client headers', function (done) {
if (typeof window !== 'undefined') {
done();
return;
}
Expand Down Expand Up @@ -33,12 +33,12 @@ describe("integration tests: client headers", function (done) {
});
});

it("sends client via headers", function (done) {
it('sends client via headers', function (done) {
let server;

const requestHandler = (request, response) => {
expect(request.headers["x-client-name"]).to.be.equal("js-stellar-sdk");
expect(request.headers["x-client-version"]).to.match(versionPattern);
expect(request.headers['x-client-name']).to.be.equal('js-stellar-sdk');
expect(request.headers['x-client-version']).to.match(versionPattern);
response.end();
server.close(() => done());
};
Expand All @@ -56,15 +56,15 @@ describe("integration tests: client headers", function (done) {
});
});

it("sends client data via get params when streaming", function (done) {
it('sends client data via get params when streaming', function (done) {
let server;
let closeStream;

const requestHandler = (request, response) => {
// eslint-disable-next-line node/no-deprecated-api
let query = url.parse(request.url, true).query;
expect(query["X-Client-Name"]).to.be.equal("js-stellar-sdk");
expect(query["X-Client-Version"]).to.match(versionPattern);
expect(query['X-Client-Name']).to.be.equal('js-stellar-sdk');
expect(query['X-Client-Version']).to.match(versionPattern);
response.end();
server.close(() => {
closeStream();
Expand All @@ -80,13 +80,13 @@ describe("integration tests: client headers", function (done) {
}

closeStream = new StellarSdk.Server(`http://localhost:${port}`, {
allowHttp: true,
allowHttp: true
})
.operations()
.stream({
onerror: (err) => {
done(err);
},
}
});
});
});
Expand Down
3 changes: 3 additions & 0 deletions test/test-browser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-disable no-undef */
chai.use(require('chai-as-promised'));
window.SorobanClient = StellarSdk.SorobanClient;
window.axios = StellarSdk.axios;
window.AxiosClient = StellarSdk.AxiosClient;

global.serverUrl = 'https://horizon-live.stellar.org:1337/api/v1/jsonrpc';

0 comments on commit 1ebc4da

Please sign in to comment.