Skip to content

Commit 053f5a2

Browse files
committed
Update server spec
1 parent 9724153 commit 053f5a2

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/server.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ import { Integrator } from '../src/integrator.js';
44
enableFetchMocks();
55
beforeEach(() => fetchMock.resetMocks());
66

7-
const MAKE_API_KEY = 'api-key';
8-
const MAKE_ZONE = 'make.local';
9-
const MAKE_TEAM = 1;
7+
const INTEGRATOR_API_KEY = 'api-key';
8+
const INTEGRATOR_BASE_URL = 'integrator.local';
9+
const INTEGRATOR_TEAM = 1;
1010

1111
import * as scenariosMock from './mocks/scenarios.json';
1212
import * as interfaceMock from './mocks/interface.json';
1313
import * as runMock from './mocks/run.json';
1414
import * as runErrorMock from './mocks/run-error.json';
15-
import { MakeError, remap } from '../src/utils.js';
15+
import { IntegratorError, remap } from '../src/utils.js';
1616

17-
describe('Make SDK', () => {
18-
const make = new Make(MAKE_API_KEY, MAKE_ZONE);
17+
describe('Integrator SDK', () => {
18+
const integrator = new Integrator(INTEGRATOR_API_KEY, 2, INTEGRATOR_BASE_URL);
1919

2020
it('Should get list of scenarios', async () => {
2121
fetchMock.mockResponse(req => {
22-
if (req.url !== 'https://make.local/api/v2/scenarios?teamId=1&pg[limit]=1000')
22+
if (req.url !== 'https://integrator.local/api/v2/scenarios?teamId=1&pg[limit]=1000')
2323
throw new Error(`Unmocked HTTP request: ${req.url}`);
2424

2525
return Promise.resolve({
@@ -30,12 +30,12 @@ describe('Make SDK', () => {
3030
});
3131
});
3232

33-
expect(await make.scenarios.list(MAKE_TEAM)).toStrictEqual(scenariosMock.scenarios);
33+
expect(await integrator.scenarios.list(INTEGRATOR_TEAM)).toStrictEqual(scenariosMock.scenarios);
3434
});
3535

3636
it('Should get scenario interface', async () => {
3737
fetchMock.mockResponse(req => {
38-
if (req.url !== 'https://make.local/api/v2/scenarios/1/interface')
38+
if (req.url !== 'https://integrator.local/api/v2/scenarios/1/interface')
3939
throw new Error(`Unmocked HTTP request: ${req.url}`);
4040

4141
return Promise.resolve({
@@ -46,12 +46,12 @@ describe('Make SDK', () => {
4646
});
4747
});
4848

49-
expect(await make.scenarios.interface(1)).toStrictEqual(interfaceMock.interface);
49+
expect(await integrator.scenarios.interface(1)).toStrictEqual(interfaceMock.interface);
5050
});
5151

5252
it('Should run scenario', async () => {
5353
fetchMock.mockResponse(req => {
54-
if (req.url !== 'https://make.local/api/v2/scenarios/1/run')
54+
if (req.url !== 'https://integrator.local/api/v2/scenarios/1/run')
5555
throw new Error(`Unmocked HTTP request: ${req.url}`);
5656

5757
return Promise.resolve({
@@ -62,12 +62,12 @@ describe('Make SDK', () => {
6262
});
6363
});
6464

65-
expect(await make.scenarios.run(1, {})).toStrictEqual(runMock);
65+
expect(await integrator.scenarios.run(1, {})).toStrictEqual(runMock);
6666
});
6767

6868
it('Should handle error in scenario run', async () => {
6969
fetchMock.mockResponse(req => {
70-
if (req.url !== 'https://make.local/api/v2/scenarios/1/run')
70+
if (req.url !== 'https://integrator.local/api/v2/scenarios/1/run')
7171
throw new Error(`Unmocked HTTP request: ${req.url}`);
7272

7373
return Promise.resolve({
@@ -80,10 +80,10 @@ describe('Make SDK', () => {
8080
});
8181

8282
try {
83-
await make.scenarios.run(1, {});
83+
await integrator.scenarios.run(1, {});
8484
throw new Error('Should throw an error.');
8585
} catch (err: unknown) {
86-
if (!(err instanceof MakeError)) throw new Error('Should throw MakeError.');
86+
if (!(err instanceof IntegratorError)) throw new Error('Should throw MakeError.');
8787

8888
expect(err.name).toBe('MakeError');
8989
expect(err.message).toBe('Validation failed for 1 parameter(s).');

0 commit comments

Comments
 (0)