Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ws-manager-bridge/src/bridge.spec.ts
2498 views
1
/**
2
* Copyright (c) 2024 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { suite, test } from "@testdeck/mocha";
8
import * as chai from "chai";
9
import { WorkspaceConditions, WorkspaceStatus } from "@gitpod/ws-manager/lib";
10
import { hasRelevantDiff } from "./bridge";
11
12
const expect = chai.expect;
13
14
function createTestStatus(statusVersion: number, failed: string): WorkspaceStatus {
15
const conditions = new WorkspaceConditions();
16
conditions.setFailed(failed);
17
const status = new WorkspaceStatus();
18
status.setStatusVersion(statusVersion);
19
status.setConditions(conditions);
20
return status;
21
}
22
23
@suite
24
class TestBridge {
25
@test public testWorkspaceStatus_hasRelevantDiff() {
26
const a = createTestStatus(123, "why on why");
27
const actual1 = hasRelevantDiff(a, a);
28
expect(actual1, "identical: no diff").to.be.false;
29
30
const b = createTestStatus(124, "why on why");
31
const actual2 = hasRelevantDiff(a, b);
32
expect(actual2, "should be same despite different statusVersion").to.equal(false);
33
34
const c = createTestStatus(125, "because!");
35
const actual3 = hasRelevantDiff(a, c);
36
expect(actual3, "different failed condition").to.equal(true);
37
}
38
}
39
module.exports = new TestBridge(); // Only to circumvent no usage warning :-/
40
41