Skip to content

Commit 8eed8a7

Browse files
committed
add api converter tests
1 parent 408f997 commit 8eed8a7

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

components/gitpod-protocol/src/public-api-converter.spec.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ import {
2222
PrebuildSettings,
2323
WorkspaceSettings,
2424
} from "@gitpod/public-api/lib/gitpod/v1/configuration_pb";
25-
import { AuthProviderEntry, AuthProviderInfo, ProjectEnvVar, UserEnvVarValue, WithEnvvarsContext } from "./protocol";
25+
import {
26+
AuthProviderEntry,
27+
AuthProviderInfo,
28+
ProjectEnvVar,
29+
SuggestedRepository,
30+
Token,
31+
UserEnvVarValue,
32+
WithEnvvarsContext,
33+
} from "./protocol";
2634
import {
2735
AuthProvider,
2836
AuthProviderDescription,
@@ -951,4 +959,43 @@ describe("PublicAPIConverter", () => {
951959
});
952960
});
953961
});
962+
describe("toSCMToken", () => {
963+
it("should convert a token", () => {
964+
const t1 = new Date();
965+
const token: Token = {
966+
scopes: ["foo"],
967+
value: "secret",
968+
refreshToken: "refresh!",
969+
username: "root",
970+
idToken: "nope",
971+
expiryDate: t1.toISOString(),
972+
updateDate: t1.toISOString(),
973+
};
974+
expect(converter.toSCMToken(token).toJson()).to.deep.equal({
975+
expiryDate: t1.toISOString(),
976+
idToken: "nope",
977+
refreshToken: "refresh!",
978+
scopes: ["foo"],
979+
updateDate: t1.toISOString(),
980+
username: "root",
981+
value: "secret",
982+
});
983+
});
984+
});
985+
describe("toSuggestedRepository", () => {
986+
it("should convert a repo", () => {
987+
const repo: SuggestedRepository = {
988+
url: "https://github.com/gitpod-io/gitpod",
989+
projectId: "123",
990+
projectName: "Gitpod",
991+
repositoryName: "gitpod",
992+
};
993+
expect(converter.toSuggestedRepository(repo).toJson()).to.deep.equal({
994+
url: "https://github.com/gitpod-io/gitpod",
995+
configurationId: "123",
996+
configurationName: "Gitpod",
997+
repoName: "gitpod",
998+
});
999+
});
1000+
});
9541001
});

0 commit comments

Comments
 (0)