zavadil-ts-common 1.2.30 → 1.2.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/RestClient.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/jest.config.js +9 -1
- package/package.json +1 -1
- package/src/client/RestClient.ts +16 -4
- package/tests/index.test.ts +20 -0
package/tests/index.test.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { StringUtil } from '../src/util/StringUtil';
|
2
2
|
import {JsonUtil} from "../src/util/JsonUtil";
|
3
|
+
import {RestClient} from "../src";
|
3
4
|
|
4
5
|
describe('testing StringUtil', () => {
|
5
6
|
test('getNonEmpty', () => {
|
@@ -30,3 +31,22 @@ describe('testing JsonUtil', () => {
|
|
30
31
|
expect(parsed.nval).toBe(13);
|
31
32
|
});
|
32
33
|
});
|
34
|
+
|
35
|
+
describe('testing RestClient', () => {
|
36
|
+
test('getUrl', () => {
|
37
|
+
const clientAbs = new RestClient('https://localhost/rel');
|
38
|
+
expect(clientAbs.getBaseUrl().href).toBe('https://localhost/rel/');
|
39
|
+
expect(clientAbs.getUrl('/test').href).toBe('https://localhost/rel/test');
|
40
|
+
expect(clientAbs.getUrl('test').href).toBe('https://localhost/rel/test');
|
41
|
+
|
42
|
+
const clientRel = new RestClient('/rel');
|
43
|
+
expect(clientRel.getBaseUrl().href).toBe('http://localhost/rel/');
|
44
|
+
expect(clientRel.getUrl('/test').href).toBe('http://localhost/rel/test');
|
45
|
+
expect(clientRel.getUrl('test').href).toBe('http://localhost/rel/test');
|
46
|
+
|
47
|
+
const clientNoLead = new RestClient('rel/');
|
48
|
+
expect(clientNoLead.getBaseUrl().href).toBe('http://localhost/rel/');
|
49
|
+
expect(clientNoLead.getUrl('/test').href).toBe('http://localhost/rel/test');
|
50
|
+
expect(clientNoLead.getUrl('test').href).toBe('http://localhost/rel/test');
|
51
|
+
});
|
52
|
+
});
|