Skip to content

Commit 4171013

Browse files
Added missing 'source' getter on Spec02
Signed-off-by: Michele Angioni <[email protected]>
1 parent 2cc5999 commit 4171013

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

lib/specs/spec_0_2.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ Spec02.prototype.source = function(_source){
5959
return this;
6060
};
6161

62+
Spec02.prototype.getSource = function() {
63+
return this.payload["source"];
64+
};
65+
6266
Spec02.prototype.id = function(_id){
6367
this.payload["id"] = _id;
6468
return this;

test/cloudevent_spec_0_1.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ var cloudevent = new Cloudevent()
1515

1616
describe("CloudEvents Spec 0.1 - JavaScript SDK", () => {
1717

18+
describe("Object properties", () => {
19+
20+
describe("Attribute getters", () => {
21+
it("returns 'type'", () => {
22+
expect(cloudevent.getType()).to.equal(type);
23+
});
24+
25+
it("returns 'source'", () => {
26+
expect(cloudevent.getSource()).to.equal(source);
27+
});
28+
});
29+
});
30+
1831
describe("JSON Format", () => {
1932

2033
describe("Required context attributes", () => {

test/cloudevent_spec_0_2.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@ const contenttype = "application/json";
99
const data = {};
1010
const extensions = {};
1111

12-
var cloudevent =
12+
var cloudevent =
1313
new Cloudevent(Cloudevent.specs["0.2"])
1414
.type(type)
1515
.source(source);
1616

1717
describe("CloudEvents Spec 0.2 - JavaScript SDK", () => {
1818

19+
describe("Object properties", () => {
20+
21+
describe("Attribute getters", () => {
22+
it("returns 'type'", () => {
23+
expect(cloudevent.getType()).to.equal(type);
24+
});
25+
26+
it("returns 'source'", () => {
27+
expect(cloudevent.getSource()).to.equal(source);
28+
});
29+
});
30+
});
31+
1932
describe("JSON Format", () => {
2033

2134
describe("Required context attributes", () => {
@@ -68,8 +81,8 @@ describe("CloudEvents Spec 0.2 - JavaScript SDK", () => {
6881
});
6982

7083
it("should throw an error when employ reserved name as extension", () => {
71-
72-
var cevt =
84+
85+
var cevt =
7386
new Cloudevent(Cloudevent.specs["0.2"])
7487
.type(type)
7588
.source(source);

0 commit comments

Comments
 (0)