@openmrs/esm-api 6.0.1-pre.2568 → 6.0.1-pre.2569

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.
@@ -10,4 +10,4 @@ built modules 144 KiB [built]
10
10
  cacheable modules 144 KiB
11
11
  ./src/index.ts + 51 modules 136 KiB [built] [code generated]
12
12
  ../esm-state/dist/openmrs-esm-state.js 8.12 KiB [built] [code generated]
13
- webpack 5.88.0 compiled successfully in 4580 ms
13
+ webpack 5.88.0 compiled successfully in 4708 ms
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-api",
3
- "version": "6.0.1-pre.2568",
3
+ "version": "6.0.1-pre.2569",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The javascript module for interacting with the OpenMRS API",
6
6
  "browser": "dist/openmrs-esm-api.js",
@@ -48,10 +48,10 @@
48
48
  "@openmrs/esm-offline": "5.x"
49
49
  },
50
50
  "devDependencies": {
51
- "@openmrs/esm-config": "6.0.1-pre.2568",
52
- "@openmrs/esm-error-handling": "6.0.1-pre.2568",
53
- "@openmrs/esm-navigation": "6.0.1-pre.2568",
54
- "@openmrs/esm-state": "6.0.1-pre.2568",
51
+ "@openmrs/esm-config": "6.0.1-pre.2569",
52
+ "@openmrs/esm-error-handling": "6.0.1-pre.2569",
53
+ "@openmrs/esm-navigation": "6.0.1-pre.2569",
54
+ "@openmrs/esm-state": "6.0.1-pre.2569",
55
55
  "rxjs": "^6.5.3",
56
56
  "webpack": "^5.88.0"
57
57
  },
@@ -1,8 +1,7 @@
1
- import { openmrsFetch, openmrsObservableFetch } from './openmrs-fetch';
2
1
  import { isObservable } from 'rxjs';
3
-
4
2
  import { getConfig as mockGetConfig } from '@openmrs/esm-config';
5
3
  import { navigate as mockNavigate } from '@openmrs/esm-navigation';
4
+ import { openmrsFetch, openmrsObservableFetch } from './openmrs-fetch';
6
5
 
7
6
  describe('openmrsFetch', () => {
8
7
  beforeEach(() => {
@@ -25,28 +24,28 @@ describe('openmrsFetch', () => {
25
24
  });
26
25
 
27
26
  it(`throws an error if you don't pass in a url string`, () => {
28
- // @ts-ignore
27
+ // @ts-expect-error
29
28
  expect(() => openmrsFetch()).toThrow(/first argument/);
30
- // @ts-ignore
29
+ // @ts-expect-error
31
30
  expect(() => openmrsFetch({})).toThrow(/first argument/);
32
31
  });
33
32
 
34
- it(`throws an error if you pass in an invalid fetchInit object`, () => {
35
- // @ts-ignore
33
+ it('throws an error if you pass in an invalid fetchInit object', () => {
34
+ // @ts-expect-error
36
35
  expect(() => openmrsFetch('/session', 'invalid second arg')).toThrow(/second argument/);
37
36
 
38
- // @ts-ignore
37
+ // @ts-expect-error
39
38
  expect(() => openmrsFetch('/session', 123)).toThrow(/second argument/);
40
39
  });
41
40
 
42
- it(`throws an Error if there is no openmrsBase`, () => {
41
+ it('throws an Error if there is no openmrsBase', () => {
43
42
  // @ts-ignore
44
43
  delete window.openmrsBase;
45
44
 
46
45
  expect(() => openmrsFetch('/session')).toThrow(/openmrsBase/);
47
46
  });
48
47
 
49
- it(`calls window.fetch with the correct arguments for a basic GET request`, () => {
48
+ it('calls window.fetch with the correct arguments for a basic GET request', () => {
50
49
  // @ts-ignore
51
50
  window.fetch.mockReturnValue(new Promise(() => {}));
52
51
  openmrsFetch('/ws/rest/v1/session');
@@ -58,7 +57,7 @@ describe('openmrsFetch', () => {
58
57
  });
59
58
  });
60
59
 
61
- it(`calls window.fetch correctly for requests that have a request body`, () => {
60
+ it('calls window.fetch correctly for requests that have a request body', () => {
62
61
  // @ts-ignore
63
62
  window.fetch.mockReturnValue(new Promise(() => {}));
64
63
  const requestBody = { some: 'json' };
@@ -76,7 +75,7 @@ describe('openmrsFetch', () => {
76
75
  });
77
76
  });
78
77
 
79
- it(`allows you to specify your own Accept request header`, () => {
78
+ it('allows you to specify your own Accept request header', () => {
80
79
  // @ts-ignore
81
80
  window.fetch.mockReturnValue(new Promise(() => {}));
82
81
  const requestBody = { some: 'json' };
@@ -93,7 +92,7 @@ describe('openmrsFetch', () => {
93
92
  });
94
93
  });
95
94
 
96
- it(`allows you to specify no Accept request header to be sent`, () => {
95
+ it('allows you to specify no Accept request header to be sent', () => {
97
96
  // @ts-ignore
98
97
  window.fetch.mockReturnValue(new Promise(() => {}));
99
98
  openmrsFetch('/ws/rest/v1/session', {
@@ -109,7 +108,7 @@ describe('openmrsFetch', () => {
109
108
  });
110
109
  });
111
110
 
112
- it(`returns a promise that resolves with a json object when the request succeeds`, () => {
111
+ it('returns a promise that resolves with a json object when the request succeeds', () => {
113
112
  // @ts-ignore
114
113
  window.fetch.mockReturnValue(
115
114
  Promise.resolve({
@@ -127,7 +126,7 @@ describe('openmrsFetch', () => {
127
126
  });
128
127
  });
129
128
 
130
- it(`returns a promise that resolves with null when the request succeeds with HTTP 204`, () => {
129
+ it('returns a promise that resolves with null when the request succeeds with HTTP 204', () => {
131
130
  // @ts-ignore
132
131
  window.fetch.mockReturnValue(
133
132
  Promise.resolve({
@@ -143,7 +142,7 @@ describe('openmrsFetch', () => {
143
142
  });
144
143
  });
145
144
 
146
- it(`gives you an amazing error when the server responds with a 500 that has json`, () => {
145
+ it('gives you an amazing error when the server responds with a 500 that has json', () => {
147
146
  // @ts-ignore
148
147
  window.fetch.mockReturnValue(
149
148
  Promise.resolve({
@@ -173,7 +172,7 @@ describe('openmrsFetch', () => {
173
172
  });
174
173
  });
175
174
 
176
- it(`gives you an amazing error when the server responds with a 400 that doesn't have json`, () => {
175
+ it("gives you an amazing error when the server responds with a 400 that doesn't have json", () => {
177
176
  // @ts-ignore
178
177
  window.fetch.mockReturnValue(
179
178
  Promise.resolve({
@@ -198,7 +197,7 @@ describe('openmrsFetch', () => {
198
197
  });
199
198
  });
200
199
 
201
- it(`navigates to spa login page when the server responds with a 401`, () => {
200
+ it('navigates to spa login page when the server responds with a 401', () => {
202
201
  (mockGetConfig as any).mockResolvedValueOnce({
203
202
  redirectAuthFailure: {
204
203
  enabled: true,
@@ -234,7 +233,7 @@ describe('openmrsObservableFetch', () => {
234
233
  window.fetch = jest.fn();
235
234
  });
236
235
 
237
- it(`calls window.fetch with the correct arguments for a basic GET request`, (done) => {
236
+ it('calls window.fetch with the correct arguments for a basic GET request', (done) => {
238
237
  // @ts-ignore
239
238
  window.fetch.mockReturnValue(
240
239
  Promise.resolve({
@@ -266,7 +265,7 @@ describe('openmrsObservableFetch', () => {
266
265
  expect(window.fetch.mock.calls[0][1].headers.Accept).toEqual('application/json');
267
266
  });
268
267
 
269
- it(`aborts the fetch request when subscription is unsubscribed`, () => {
268
+ it('aborts the fetch request when subscription is unsubscribed', () => {
270
269
  // @ts-ignore
271
270
  window.fetch.mockReturnValue(new Promise(() => {}));
272
271