@@ -4,6 +4,10 @@ var Cloudevent = require("../index.js");
4
4
const type = "com.github.pull.create" ;
5
5
const source = "urn:event:from:myapi/resourse/123" ;
6
6
const time = new Date ( ) ;
7
+ const schemaurl = "http://example.com/registry/myschema.json" ;
8
+ const contenttype = "application/json" ;
9
+ const data = { } ;
10
+ const extensions = { } ;
7
11
8
12
var cloudevent = new Cloudevent ( )
9
13
. type ( type )
@@ -18,6 +22,11 @@ describe("CloudEvents Spec 0.1 - JavaScript SDK", () => {
18
22
expect ( cloudevent . format ( ) ) . to . have . property ( 'eventType' ) ;
19
23
} ) ;
20
24
25
+ it ( "requires 'eventTypeVersion'" , ( ) => {
26
+ cloudevent . eventTypeVersion ( "1.0" ) ;
27
+ expect ( cloudevent . format ( ) ) . to . have . property ( 'eventTypeVersion' ) ;
28
+ } ) ;
29
+
21
30
it ( "requires 'cloudEventsVersion'" , ( ) => {
22
31
expect ( cloudevent . format ( ) ) . to . have . property ( 'cloudEventsVersion' ) ;
23
32
} ) ;
@@ -31,11 +40,38 @@ describe("CloudEvents Spec 0.1 - JavaScript SDK", () => {
31
40
} ) ;
32
41
} ) ;
33
42
34
- describe ( "Backward compatibility" , ( ) => {
35
- it ( "should have 'eventTypeVersion'" , ( ) => {
36
- cloudevent . eventTypeVersion ( "1.0" ) ;
37
- expect ( cloudevent . format ( ) ) . to . have . property ( 'eventTypeVersion' ) ;
43
+ describe ( "Optional context attributes" , ( ) => {
44
+ it ( "contains 'eventTime'" , ( ) => {
45
+ cloudevent . time ( time ) ;
46
+ expect ( cloudevent . format ( ) ) . to . have . property ( 'eventTime' ) ;
47
+ } ) ;
48
+
49
+ it ( "contains 'schemaURL'" , ( ) => {
50
+ cloudevent . schemaurl ( schemaurl ) ;
51
+ expect ( cloudevent . format ( ) ) . to . have . property ( 'schemaURL' ) ;
52
+ } ) ;
53
+
54
+ it ( "contains 'contentType'" , ( ) => {
55
+ cloudevent . contenttype ( contenttype ) ;
56
+ expect ( cloudevent . format ( ) ) . to . have . property ( 'contentType' ) ;
57
+ } ) ;
58
+
59
+ it ( "contains 'data'" , ( ) => {
60
+ cloudevent . data ( data ) ;
61
+ expect ( cloudevent . format ( ) ) . to . have . property ( 'data' ) ;
62
+ } ) ;
63
+
64
+ it ( "contains 'extensions'" , ( ) => {
65
+ cloudevent . addExtension ( 'foo' , 'value' ) ;
66
+ expect ( cloudevent . format ( ) ) . to . have . property ( 'extensions' ) ;
67
+ } ) ;
68
+
69
+ it ( "'extensions' should have 'bar' extension" , ( ) => {
70
+ cloudevent . addExtension ( 'bar' , 'value' ) ;
71
+ expect ( cloudevent . format ( ) . extensions )
72
+ . to . have . property ( 'foo' ) ;
38
73
} ) ;
74
+
39
75
} ) ;
40
76
41
77
describe ( "The Constraint check" , ( ) => {
0 commit comments