Skip to content

Commit c1292a8

Browse files
committed
Unit testing for time attribute format
Signed-off-by: Fabio José <[email protected]>
1 parent 0568d43 commit c1292a8

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

test/cloudevent_spec_0_1.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
var expect = require("chai").expect;
22
var Cloudevent = require("../index.js");
33

4-
const type = "com.github.pull.create";
4+
const type = "com.github.pull.create";
5+
const source = "urn:event:from:myapi/resourse/123";
6+
const time = new Date();
57

68
var cloudevent = new Cloudevent()
79
.type(type)
8-
.source("urn:event:from:myapi/resourse/123");
10+
.source(source);
911

1012
describe("CloudEvents Spec 0.1 - JavaScript SDK", () => {
1113

@@ -45,10 +47,23 @@ describe("CloudEvents Spec 0.1 - JavaScript SDK", () => {
4547
.throw("'eventType' is invalid");
4648
});
4749

48-
it("should be a non-empty string", () => {
50+
it("must be a non-empty string", () => {
4951
cloudevent.type(type);
5052
cloudevent.format();
5153
});
54+
55+
it("should be prefixed with a reverse-DNS name", () => {
56+
//TODO how to assert it?
57+
});
58+
});
59+
60+
//TODO another attributes . . .
61+
62+
describe("'eventTime'", () => {
63+
it("must adhere to the format specified in RFC 3339", () => {
64+
cloudevent.time(time);
65+
expect(cloudevent.format()['eventTime']).to.equal(time.toISOString());
66+
});
5267
});
5368
});
5469

0 commit comments

Comments
 (0)