Skip to content

Commit c6b8290

Browse files
committed
test(urls): include endpoint URLs for the tests
1 parent 0412edb commit c6b8290

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/contexts/contexts.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { Hyper } from '../index';
33

44
enableFetchMocks();
55

6+
const baseUrl = process.env.HYPER_BASE_URL || 'https://api.gethyper.ai/v1';
7+
const endpoint = '/contexts';
8+
const fullEndpoint = `${baseUrl}${endpoint}`;
9+
610
const hyper = new Hyper('hyper_1234');
711

812
describe('Hypercode contexts API methods', () => {
@@ -36,7 +40,7 @@ describe('Hypercode contexts API methods', () => {
3640

3741
expect(result.data).toEqual(expectedResult);
3842
expect(fetchMock).toHaveBeenLastCalledWith(
39-
expect.any(String), // endpoint
43+
fullEndpoint, // endpoint
4044
// body and headers
4145
expect.any(Object),
4246
);

src/search/search.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { Hyper } from '../index';
33

44
enableFetchMocks();
55

6+
const baseUrl = process.env.HYPER_BASE_URL || 'https://api.gethyper.ai/v1';
7+
const endpoint = '/search';
8+
const fullEndpoint = `${baseUrl}${endpoint}`;
9+
610
const hyper = new Hyper('hyper_1234');
711

812
describe('Hypercode Search API methods', () => {
@@ -45,7 +49,7 @@ describe('Hypercode Search API methods', () => {
4549

4650
expect(result.data).toEqual(expectedResult);
4751
expect(fetchMock).toHaveBeenLastCalledWith(
48-
expect.any(String), // endpoint
52+
fullEndpoint, // endpoint
4953
// body and headers
5054
expect.objectContaining({
5155
body: expect.stringContaining(

src/types/types.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { enableFetchMocks } from 'jest-fetch-mock';
22
import { Hyper } from '../index';
3+
import type { AllowedTypes } from './@types';
34

45
enableFetchMocks();
56

7+
const baseUrl = process.env.HYPER_BASE_URL || 'https://api.gethyper.ai/v1';
8+
const endpoint = '/types';
9+
const fullEndpoint = (type: AllowedTypes) => `${baseUrl}${endpoint}/${type}`;
10+
611
const hyper = new Hyper('hyper_1234');
712

813
describe('Hypercode Types API methods', () => {
@@ -34,7 +39,7 @@ describe('Hypercode Types API methods', () => {
3439
expect(typeof result.data).toBe('string');
3540
expect(result.data).toBe('Elon Musk');
3641
expect(fetchMock).toHaveBeenLastCalledWith(
37-
expect.any(String), // endpoint
42+
fullEndpoint('string'), // endpoint
3843
// body and headers
3944
expect.objectContaining({
4045
body: expect.stringContaining(
@@ -69,15 +74,15 @@ describe('Hypercode Types API methods', () => {
6974
status: 200,
7075
});
7176

72-
const result = await hyper.types.string(
77+
const result = await hyper.types.integer(
7378
'How many planets are in the Solar System?',
7479
{ contextId },
7580
);
7681

7782
expect(typeof result.data).toBe('number');
7883
expect(result.data).toBe(42);
7984
expect(fetchMock).toHaveBeenLastCalledWith(
80-
expect.any(String), // endpoint
85+
fullEndpoint('integer'), // endpoint
8186
// body and headers
8287
expect.objectContaining({
8388
body: expect.stringContaining(
@@ -123,7 +128,7 @@ describe('Hypercode Types API methods', () => {
123128
expect(typeof result.data).toBe('number');
124129
expect(result.data).toBe(fixedStatistic);
125130
expect(fetchMock).toHaveBeenLastCalledWith(
126-
expect.any(String), // endpoint
131+
fullEndpoint('float'), // endpoint
127132
// body and headers
128133
expect.objectContaining({
129134
body: expect.stringContaining(
@@ -163,7 +168,7 @@ describe('Hypercode Types API methods', () => {
163168
expect(typeof result.data).toBe('boolean');
164169
expect(result.data).toBe(true);
165170
expect(fetchMock).toHaveBeenLastCalledWith(
166-
expect.any(String), // endpoint
171+
fullEndpoint('boolean'), // endpoint
167172
// body and headers
168173
expect.objectContaining({
169174
body: expect.stringContaining(
@@ -210,7 +215,7 @@ describe('Hypercode Types API methods', () => {
210215
expect(new Date(data!)).toBeInstanceOf(Date);
211216
expect(new Date(data!).getFullYear()).toBe(1969);
212217
expect(fetchMock).toHaveBeenLastCalledWith(
213-
expect.any(String), // endpoint
218+
fullEndpoint('datetime'), // endpoint
214219
// body and headers
215220
expect.objectContaining({
216221
body: expect.stringContaining(

0 commit comments

Comments
 (0)