Skip to content

Commit 202b6bb

Browse files
author
Dennis Labordus
committed
Added test + fixed snapshots.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 129d4b2 commit 202b6bb

23 files changed

+207
-169
lines changed

test/integration/compas-editors/CompasVersions.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ describe('compas-versions-plugin', () => {
4141
});
4242

4343
it('looks like the latest snapshot', async () => {
44-
expect(element).shadowDom
45-
.to.equalSnapshot();
44+
await expect(element).shadowDom.to.equalSnapshot();
4645
sinon.assert.notCalled(stub);
4746
});
4847
});
@@ -66,8 +65,7 @@ describe('compas-versions-plugin', () => {
6665
});
6766

6867
it('looks like the latest snapshot', async () => {
69-
expect(element).shadowDom
70-
.to.equalSnapshot();
68+
await expect(element).shadowDom.to.equalSnapshot();
7169
});
7270
});
7371

@@ -91,8 +89,7 @@ describe('compas-versions-plugin', () => {
9189
});
9290

9391
it('looks like the latest snapshot', async () => {
94-
expect(element).shadowDom
95-
.to.equalSnapshot();
92+
await expect(element).shadowDom.to.equalSnapshot();
9693
sinon.assert.calledOnce(stub);
9794
});
9895
});
@@ -143,8 +140,7 @@ describe('compas-versions-plugin', () => {
143140
});
144141

145142
it('looks like the latest snapshot', async () => {
146-
expect(element).shadowDom
147-
.to.equalSnapshot();
143+
await expect(element).shadowDom.to.equalSnapshot();
148144
sinon.assert.calledOnce(stub);
149145
});
150146
});
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import {expect} from "@open-wc/testing";
22

33
import {
4+
COMMONS_NAMESPACE,
5+
getWebsocketUri,
46
processErrorMessage,
57
} from "../../../src/compas-services/foundation.js";
68

79
const errorBody =
810
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
9-
<compas-commons:ErrorResponse xmlns:compas-commons="https://www.lfenergy.org/compas/commons/v1">
11+
<compas-commons:ErrorResponse xmlns:compas-commons="${COMMONS_NAMESPACE}">
1012
<compas-commons:ErrorMessage>
1113
<compas-commons:Code>CORE-8000</compas-commons:Code>
1214
<compas-commons:Message>Name is not a correct name to be used later as filename.</compas-commons:Message>
@@ -15,19 +17,31 @@ const errorBody =
1517
</compas-commons:ErrorResponse>`;
1618

1719
describe('compas-services-foundation', () => {
18-
it('when there is no body in the response, the status text will be returned', async () => {
19-
const statusText = 'some status text';
20-
const response = new Response(null, <ResponseInit>{statusText: statusText});
21-
const result = await processErrorMessage(response);
22-
expect(result).to.be.equal(statusText);
23-
})
24-
it('when there is a body in the response, the message is retrieved from the body', async () => {
25-
const expectedMessage = 'Name is not a correct name to be used later as filename. (CORE-8000)'
26-
const statusText = 'some status text';
27-
const response = new Response(errorBody, <ResponseInit>{statusText: statusText});
28-
const result = await processErrorMessage(response);
29-
expect(result).to.be.equal(expectedMessage);
20+
describe('execute processErrorMessage', () => {
21+
it('when there is no body in the response, the status text will be returned', async () => {
22+
const statusText = 'some status text';
23+
const response = new Response(null, <ResponseInit>{statusText: statusText});
24+
const result = await processErrorMessage(response);
25+
expect(result).to.be.equal(statusText);
26+
});
3027

31-
})
28+
it('when there is a body in the response, the message is retrieved from the body', async () => {
29+
const expectedMessage = 'Name is not a correct name to be used later as filename. (CORE-8000)'
30+
const statusText = 'some status text';
31+
const response = new Response(errorBody, <ResponseInit>{statusText: statusText});
32+
const result = await processErrorMessage(response);
33+
expect(result).to.be.equal(expectedMessage);
34+
});
35+
});
36+
37+
describe('execute getWebsocketUri', () => {
38+
it('when full http url passed then http replaced with ws', () => {
39+
expect(getWebsocketUri("http://somesite.com/path")).to.be.equal("ws://somesite.com/path")
40+
});
41+
42+
it('when full https url passed then http replaced with ws', () => {
43+
expect(getWebsocketUri("https://somesite.com/path")).to.be.equal("wss://somesite.com/path")
44+
});
45+
});
3246
});
3347

test/unit/compas/CompasAutoAlignment.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ describe('compas-auto-alignment', () => {
4747
.to.contains("_974565b1-ac55-4901-9f48-afc7ef5486df");
4848
});
4949

50-
it('looks like the latest snapshot', () => {
51-
expect(element).shadowDom
52-
.to.equalSnapshot();
50+
it('looks like the latest snapshot', async () => {
51+
await expect(element).shadowDom.to.equalSnapshot();
5352
});
5453
});
5554

@@ -69,9 +68,8 @@ describe('compas-auto-alignment', () => {
6968
.to.have.length(0)
7069
});
7170

72-
it('looks like the latest snapshot', () => {
73-
expect(element).shadowDom
74-
.to.equalSnapshot();
71+
it('looks like the latest snapshot', async () => {
72+
await expect(element).shadowDom.to.equalSnapshot();
7573
});
7674
});
7775
});

test/unit/compas/CompasChangeSet.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ describe('compas-changeset-radiogroup', () => {
4545
.to.be.equal(ChangeSet.MAJOR)
4646
});
4747

48-
it('looks like the latest snapshot', () => {
49-
expect(element).shadowDom
50-
.to.equalSnapshot();
48+
it('looks like the latest snapshot', async () => {
49+
await expect(element).shadowDom.to.equalSnapshot();
5150
});
5251
});

test/unit/compas/CompasComment.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ describe('compas-comment', () => {
2828
.to.be.equal(value)
2929
});
3030

31-
it('looks like the latest snapshot', () => {
32-
expect(element).shadowDom
33-
.to.equalSnapshot();
31+
it('looks like the latest snapshot', async () => {
32+
await expect(element).shadowDom.to.equalSnapshot();
3433
});
3534

3635
function setValue(value: string) {

test/unit/compas/CompasCompareDialog.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ describe('compas-compare-dialog', () => {
6262
await element;
6363
});
6464

65-
it('looks like the latest snapshot', () => {
66-
expect(element).to.equalSnapshot();
65+
it('looks like the latest snapshot', async () => {
66+
await expect(element).to.equalSnapshot();
6767
});
6868
});
6969
});

test/unit/compas/CompasImportFromApi.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('compas-import-from-api', () => {
1111
await element;
1212
});
1313

14-
it('looks like the latest snapshot', () => {
15-
expect(element).shadowDom.to.equalSnapshot();
14+
it('looks like the latest snapshot', async () => {
15+
await expect(element).shadowDom.to.equalSnapshot();
1616
});
1717
});

test/unit/compas/CompasLoading.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ describe('compas-loading', () => {
1111
);
1212
});
1313

14-
it('looks like the latest snapshot', () => {
15-
expect(element).shadowDom
16-
.to.equalSnapshot();
14+
it('looks like the latest snapshot', async () => {
15+
await expect(element).shadowDom.to.equalSnapshot();
1716
});
1817
});

test/unit/compas/CompasOpen.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ describe('compas-open', () => {
1414
await element;
1515
});
1616

17-
it('looks like the latest snapshot', () => {
18-
expect(element).shadowDom.to.equalSnapshot();
17+
it('looks like the latest snapshot', async () => {
18+
await expect(element).shadowDom.to.equalSnapshot();
1919
});
2020
});
2121

@@ -34,8 +34,8 @@ describe('compas-open', () => {
3434
expect(element.selectedType).to.be.undefined;
3535
});
3636

37-
it('looks like the latest snapshot', () => {
38-
expect(element).shadowDom.to.equalSnapshot();
37+
it('looks like the latest snapshot', async () => {
38+
await expect(element).shadowDom.to.equalSnapshot();
3939
});
4040
});
4141
});

test/unit/compas/CompasSave.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ describe('compas-save', () => {
2424
await element;
2525
});
2626

27-
it('looks like the latest snapshot', () => {
28-
expect(element).shadowDom
29-
.to.equalSnapshot();
27+
it('looks like the latest snapshot', async () => {
28+
await expect(element).shadowDom.to.equalSnapshot();
3029
});
3130
});
3231

@@ -44,9 +43,8 @@ describe('compas-save', () => {
4443
await waitUntil(() => element.existInCompas !== undefined);
4544
});
4645

47-
it('looks like the latest snapshot', () => {
48-
expect(element).shadowDom
49-
.to.equalSnapshot();
46+
it('looks like the latest snapshot', async () => {
47+
await expect(element).shadowDom.to.equalSnapshot();
5048
});
5149
});
5250

@@ -65,9 +63,8 @@ describe('compas-save', () => {
6563

6664
});
6765

68-
it('looks like the latest snapshot', () => {
69-
expect(element).shadowDom
70-
.to.equalSnapshot();
66+
it('looks like the latest snapshot', async () => {
67+
await expect(element).shadowDom.to.equalSnapshot();
7168
});
7269
})
7370

0 commit comments

Comments
 (0)