Skip to content

Commit

Permalink
fixup! chore(tests): update tests wrt api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vegardok committed Oct 8, 2021
1 parent 95758cf commit 1ed36a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
15 changes: 10 additions & 5 deletions packages/beta/src/__tests__/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ export function setupClient(baseUrl: string = Constants.BASE_URL) {
appId: 'JS SDK integration tests (beta)',
project: process.env.COGNITE_PROJECT || (project as string),
apiKeyMode: true,
getToken: () =>
Promise.resolve(process.env.COGNITE_CREDENTIALS || (apiKey as string)),
getToken: () => Promise.resolve(apiKey as string),
baseUrl,
});
}

export function setupLoggedInClient() {
const client = setupClient();
return client;
export function setupLoggedInClient(baseUrl: string = Constants.BASE_URL) {
return new CogniteClient({
appId: 'JS SDK integration tests (beta)',
project: process.env.COGNITE_PROJECT || (project as string),
apiKeyMode: true,
getToken: () =>
Promise.resolve(process.env.COGNITE_CREDENTIALS || (apiKey as string)),
baseUrl,
});
}

export function setupMockableClient() {
Expand Down
2 changes: 2 additions & 0 deletions packages/stable/src/__tests__/api/login.int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('Login-api integration test', () => {

describe('status', () => {
test('logged in', async () => {
await client.authenticate();
const status = await client.login.status();
expect(status).toBeDefined();
expect(status!.project).toBeDefined();
Expand All @@ -20,6 +21,7 @@ describe('Login-api integration test', () => {

test('not logged in', async () => {
const anotherClient = setupClient();
await anotherClient.authenticate();
const status = await anotherClient.login.status();
expect(status).toBeNull();
});
Expand Down
1 change: 1 addition & 0 deletions packages/stable/src/__tests__/api/logout.int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('logout-api integration test', () => {

describe('logout url', () => {
test('logged in', async () => {
await loggedInClient.authenticate();
const url = await loggedInClient.logout.getUrl();
expect(typeof url).toBe('string');
});
Expand Down
1 change: 0 additions & 1 deletion packages/stable/src/__tests__/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function setupClient(baseUrl: string = Constants.BASE_URL) {
}

export function setupLoggedInClient() {
jest.setTimeout(60 * 1000);
return new CogniteClient({
appId: 'JS SDK integration tests',
project: process.env.COGNITE_PROJECT as string,
Expand Down

0 comments on commit 1ed36a7

Please sign in to comment.