mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-18 07:26:28 +00:00
Add unit tests for projectFromJSON's upgrade support (#1519)
This commit is contained in:
parent
fb16530b8f
commit
b7b93d2a8d
@ -10,6 +10,7 @@ import {
|
||||
} from "./project";
|
||||
|
||||
import {makeRepoId} from "./repoId";
|
||||
import {toCompat} from "../util/compat";
|
||||
|
||||
describe("core/project", () => {
|
||||
const foobar = deepFreeze(makeRepoId("foo", "bar"));
|
||||
@ -41,6 +42,58 @@ describe("core/project", () => {
|
||||
check(p1);
|
||||
check(p2);
|
||||
});
|
||||
it("should upgrade from 0.3.0 formatting", () => {
|
||||
// Given
|
||||
const body = {
|
||||
id: "example-030",
|
||||
repoIds: [foobar, foozod],
|
||||
discourseServer: {
|
||||
serverUrl: "https://example.com",
|
||||
apiUsername: "hello-test",
|
||||
},
|
||||
identities: [],
|
||||
};
|
||||
const compat = toCompat(
|
||||
{type: "sourcecred/project", version: "0.3.0"},
|
||||
body
|
||||
);
|
||||
|
||||
// When
|
||||
const project = projectFromJSON(compat);
|
||||
|
||||
// Then
|
||||
expect(project).toEqual({
|
||||
...body,
|
||||
// It should strip the apiUsername field, keeping just serverUrl.
|
||||
discourseServer: {serverUrl: "https://example.com"},
|
||||
});
|
||||
});
|
||||
it("should upgrade from 0.3.1 formatting", () => {
|
||||
// Given
|
||||
const body = {
|
||||
id: "example-031",
|
||||
repoIds: [foobar, foozod],
|
||||
discourseServer: {
|
||||
serverUrl: "https://example.com",
|
||||
apiUsername: "hello-test",
|
||||
},
|
||||
identities: [],
|
||||
};
|
||||
const compat = toCompat(
|
||||
{type: "sourcecred/project", version: "0.3.1"},
|
||||
body
|
||||
);
|
||||
|
||||
// When
|
||||
const project = projectFromJSON(compat);
|
||||
|
||||
// Then
|
||||
expect(project).toEqual({
|
||||
...body,
|
||||
// It should strip the apiUsername field, keeping just serverUrl.
|
||||
discourseServer: {serverUrl: "https://example.com"},
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("encodeProjectId", () => {
|
||||
it("is a base64-url encoded id", () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user