Skip to content

Commit

Permalink
bump version; fix types; update deps; implement better error handling (
Browse files Browse the repository at this point in the history
…closes #3);
  • Loading branch information
mosheduminer committed Jan 19, 2022
1 parent d2390d1 commit 57b0cca
Show file tree
Hide file tree
Showing 12 changed files with 2,162 additions and 6,256 deletions.
6 changes: 2 additions & 4 deletions __tests__/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {mocked} from "ts-jest/utils";

let mockedFetch = jest.fn();
jest.mock('fetch-ponyfill', () => {
return () => ({fetch: mockedFetch})
});
const Response = jest.requireActual('fetch-ponyfill')().Response;
mockedFetch = mocked(mockedFetch, true);
mockedFetch = jest.mocked(mockedFetch, true);

import Client from "../src/client";
import {initClient} from '../src/auth';
Expand Down Expand Up @@ -55,7 +53,7 @@ describe("test authentication", () => {
// an error should've already been thrown
expect(true).toEqual(false);
} catch (e) {
expect(e.message).toEqual("failed to retrieve an access token using credentials");
expect(e.message).toEqual("invalid credentials");
}
expect(errorSpy).toHaveBeenCalledWith("401, invalid credentials");
expect(debugSpy).toHaveBeenCalledWith("failed to retrieve an access token using credentials. aborting");
Expand Down
4 changes: 1 addition & 3 deletions __tests__/database.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {mocked} from "ts-jest/utils";

let mockedFetch = jest.fn();
jest.mock('fetch-ponyfill', () => {
return () => ({fetch: mockedFetch})
});
const Response = jest.requireActual('fetch-ponyfill')().Response;
mockedFetch = mocked(mockedFetch, true);
mockedFetch = jest.mocked(mockedFetch, true);

import {Sirix, sirixInit} from "../src/sirix";
import Database from "../src/database";
Expand Down
4 changes: 1 addition & 3 deletions __tests__/resource.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {mocked} from "ts-jest/utils";

let mockedFetch = jest.fn();
jest.mock('fetch-ponyfill', () => {
return () => ({fetch: mockedFetch})
});
const Response = jest.requireActual('fetch-ponyfill')().Response;
mockedFetch = mocked(mockedFetch, true);
mockedFetch = jest.mocked(mockedFetch, true);

import {Sirix, sirixInit} from "../src/sirix";
import Database from "../src/database";
Expand Down
4 changes: 1 addition & 3 deletions __tests__/sirix.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {mocked} from "ts-jest/utils";

let mockedFetch = jest.fn();
jest.mock('fetch-ponyfill', () => {
return () => ({fetch: mockedFetch})
});
const Response = jest.requireActual('fetch-ponyfill')().Response;
mockedFetch = mocked(mockedFetch, true);
mockedFetch = jest.mocked(mockedFetch, true);

import {Sirix, sirixInit} from "../src/sirix";
import {token, postQuery} from "./data";
Expand Down
4 changes: 2 additions & 2 deletions __tests__/xml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Sirix, sirixInit} from "../src/sirix";
import Database from "../src/database";
import Resource from "../src/resource";
import {DBType} from "../src/info";
import {DOMParser} from "xmldom";
import {DOMParser} from "@xmldom/xmldom";

const domParser = new DOMParser();
const xmlNode = domParser.parseFromString(`
Expand Down Expand Up @@ -39,4 +39,4 @@ describe('Test xml support', () => {
console.log(res);
expect(res).toEqual(xmlNode);*/
});
})
})
4 changes: 3 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Sirix, sirixInit} from "./src/sirix";
import Database from "./src/database";
import Resource from "./src/resource";
import {Insert} from "./src/constants";
import {Insert, ServerError, ServerErrorType} from "./src/constants";
import {
DBType,
DatabaseInfo,
Expand Down Expand Up @@ -37,4 +37,6 @@ export {
NodeType,
MetaNode,
Metadata,
ServerError,
ServerErrorType,
};
Loading

0 comments on commit 57b0cca

Please sign in to comment.