Skip to content

Commit

Permalink
feat: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-dixit committed Aug 14, 2024
1 parent c7f4678 commit 3e11b0c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_js_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
- name: pnpm build
run: cd js && pnpm build
- name: run test
run: cd js && pnpm test
run: cd js && pnpm test
4 changes: 4 additions & 0 deletions js/config/getTestConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const env = process.env.TEST_ENV || "prod"
export const getTestConfig = ():Record<string,string> => {
return require(`./test.config.${env}.json`);
}
4 changes: 4 additions & 0 deletions js/config/test.config.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"COMPOSIO_API_KEY": "cq5ke4zt8e7a1lmen823",
"BACKEND_HERMES_URL": "https://backend.composio.dev"
}
33 changes: 0 additions & 33 deletions js/src/sdk/baseClient.ts

This file was deleted.

30 changes: 30 additions & 0 deletions js/src/sdk/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { describe, it, expect } from "@jest/globals";
import {Composio} from "./index"

//@ts-ignore
import { getTestConfig } from "../../config/getTestConfig";

const COMPOSIO_API_KEY = getTestConfig()["COMPOSIO_API_KEY"]
const BACKEND_HERMES_URL = getTestConfig()["BACKEND_HERMES_URL"]

describe("Basic SDK spec suite", () => {
it("create basic client", () => {
new Composio(COMPOSIO_API_KEY)
});

it("without apiKey, error should be thrown", () => {
expect(() => {
new Composio();
}).toThrow('API key is missing');
});

it("get entity",async()=>{
const app = "github"
const composio = new Composio(COMPOSIO_API_KEY, BACKEND_HERMES_URL);
const entity = composio.getEntity("default")

expect(entity.id).toBe("default")
const connection = await entity.getConnection(app);
expect(connection.appUniqueId).toBe(app);
})
});
2 changes: 0 additions & 2 deletions js/src/sdk/models/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ export class Entity {
});
}


console.log("hi")
// Initiate the connection process
return ConnectedAccounts.initiate({
integrationId: integration!.id!,
Expand Down
2 changes: 1 addition & 1 deletion js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": "./src",
"rootDir": "./",
"sourceMap": true,
},
"include": ["src/**/*"],
Expand Down

0 comments on commit 3e11b0c

Please sign in to comment.