1+ const expect = require ( "chai" ) . expect ;
2+
3+ const {
4+ HEADERS ,
5+ CHARSET_DEFAULT ,
6+ BINARY ,
7+ STRUCTURED ,
8+ SPEC_V03 ,
9+ SPEC_V1 ,
10+ DEFAULT_SPEC_VERSION_HEADER ,
11+ ENCODING_BASE64 ,
12+ DATA_ATTRIBUTE ,
13+ MIME_JSON ,
14+ MIME_OCTET_STREAM ,
15+ MIME_CE ,
16+ MIME_CE_JSON ,
17+ HEADER_CONTENT_TYPE ,
18+ DEFAULT_CONTENT_TYPE ,
19+ DEFAULT_CE_CONTENT_TYPE ,
20+ BINARY_HEADERS_03 ,
21+ STRUCTURED_ATTRS_03 ,
22+ BINARY_HEADERS_1 ,
23+ STRUCTURED_ATTRS_1
24+ } = require ( "../" ) . Constants ;
25+
26+ describe ( "Constants exposed by top level exports" , ( ) => {
27+ it ( "Exports a HEADERS constant" , ( ) => {
28+ expect ( HEADERS ) . to . equal ( "headers" ) ;
29+ } ) ;
30+ it ( "Exports a CHARSET_DEFAULT constant" , ( ) => {
31+ expect ( CHARSET_DEFAULT ) . to . equal ( "utf-8" ) ;
32+ } ) ;
33+ it ( "Exports a BINARY constant" , ( ) => {
34+ expect ( BINARY ) . to . equal ( "binary" ) ;
35+ } ) ;
36+ it ( "Exports a STRUCTURED constant" , ( ) => {
37+ expect ( STRUCTURED ) . to . equal ( "structured" ) ;
38+ } ) ;
39+ it ( "Exports a SPEC_V03 constant" , ( ) => {
40+ expect ( SPEC_V03 ) . to . equal ( "0.3" ) ;
41+ } ) ;
42+ it ( "Exports a SPEC_V1 constant" , ( ) => {
43+ expect ( SPEC_V1 ) . to . equal ( "1.0" ) ;
44+ } ) ;
45+ it ( "Exports a DEFAULT_SPEC_VERSION_HEADER constant" , ( ) => {
46+ expect ( DEFAULT_SPEC_VERSION_HEADER ) . to . equal ( "ce-specversion" ) ;
47+ } ) ;
48+ it ( "Exports an ENCODING_BASE64 constant" , ( ) => {
49+ expect ( ENCODING_BASE64 ) . to . equal ( "base64" ) ;
50+ } ) ;
51+ it ( "Exports a DATA_ATTRIBUTE constant" , ( ) => {
52+ expect ( DATA_ATTRIBUTE ) . to . equal ( "data" ) ;
53+ } ) ;
54+ it ( "Exports a MIME_JSON constant" , ( ) => {
55+ expect ( MIME_JSON ) . to . equal ( "application/json" ) ;
56+ } ) ;
57+ it ( "Exports a MIME_OCTET_STREAM constant" , ( ) => {
58+ expect ( MIME_OCTET_STREAM ) . to . equal ( "application/octet-stream" ) ;
59+ } ) ;
60+ it ( "Exports a MIME_CE constant" , ( ) => {
61+ expect ( MIME_CE ) . to . equal ( "application/cloudevents" ) ;
62+ } ) ;
63+ it ( "Exports a MIME_CE_JSON constant" , ( ) => {
64+ expect ( MIME_CE_JSON ) . to . equal ( "application/cloudevents+json" ) ;
65+ } ) ;
66+ it ( "Exports a HEADER_CONTENT_TYPE constant" , ( ) => {
67+ expect ( HEADER_CONTENT_TYPE ) . to . equal ( "content-type" ) ;
68+ } ) ;
69+ it ( "Exports a DEFAULT_CONTENT_TYPE constant" , ( ) => {
70+ expect ( DEFAULT_CONTENT_TYPE ) . to . equal ( `${ MIME_JSON } ; charset=${ CHARSET_DEFAULT } ` ) ;
71+ } ) ;
72+ it ( "Exports a DEFAULT_CE_CONTENT_TYPE constant" , ( ) => {
73+ expect ( DEFAULT_CE_CONTENT_TYPE ) . to . equal ( `${ MIME_CE_JSON } ; charset=${ CHARSET_DEFAULT } ` ) ;
74+ } ) ;
75+ describe ( "V0.3 binary headers constants" , ( ) => {
76+ it ( "Provides a TYPE header" , ( ) => {
77+ expect ( BINARY_HEADERS_03 . TYPE ) . to . equal ( "ce-type" ) ;
78+ } ) ;
79+ it ( "Provides a SPEC_VERSION header" , ( ) => {
80+ expect ( BINARY_HEADERS_03 . SPEC_VERSION ) . to . equal ( "ce-specversion" ) ;
81+ } ) ;
82+ it ( "Provides a SOURCE header" , ( ) => {
83+ expect ( BINARY_HEADERS_03 . SOURCE ) . to . equal ( "ce-source" ) ;
84+ } ) ;
85+ it ( "Provides an ID header" , ( ) => {
86+ expect ( BINARY_HEADERS_03 . ID ) . to . equal ( "ce-id" ) ;
87+ } ) ;
88+ it ( "Provides a TIME header" , ( ) => {
89+ expect ( BINARY_HEADERS_03 . TIME ) . to . equal ( "ce-time" ) ;
90+ } ) ;
91+ it ( "Provides a SCHEMA_URL header" , ( ) => {
92+ expect ( BINARY_HEADERS_03 . SCHEMA_URL ) . to . equal ( "ce-schemaurl" ) ;
93+ } ) ;
94+ it ( "Provides a CONTENT_ENCODING header" , ( ) => {
95+ expect ( BINARY_HEADERS_03 . CONTENT_ENCONDING ) . to . equal ( "ce-datacontentencoding" ) ;
96+ } ) ;
97+ it ( "Provides a SUBJECT header" , ( ) => {
98+ expect ( BINARY_HEADERS_03 . SUBJECT ) . to . equal ( "ce-subject" ) ;
99+ } ) ;
100+ it ( "Provides an EXTENSIONS_PREFIX constant" , ( ) => {
101+ expect ( BINARY_HEADERS_03 . EXTENSIONS_PREFIX ) . to . equal ( "ce-" ) ;
102+ } ) ;
103+ } ) ;
104+ describe ( "V0.3 structured attributes constants" , ( ) => {
105+ it ( "Provides a TYPE attribute" , ( ) => {
106+ expect ( STRUCTURED_ATTRS_03 . TYPE ) . to . equal ( "type" ) ;
107+ } ) ;
108+ it ( "Provides a SPEC_VERSION attribute" , ( ) => {
109+ expect ( STRUCTURED_ATTRS_03 . SPEC_VERSION ) . to . equal ( "specversion" ) ;
110+ } ) ;
111+ it ( "Provides a SOURCE attribute" , ( ) => {
112+ expect ( STRUCTURED_ATTRS_03 . SOURCE ) . to . equal ( "source" ) ;
113+ } ) ;
114+ it ( "Provides an ID attribute" , ( ) => {
115+ expect ( STRUCTURED_ATTRS_03 . ID ) . to . equal ( "id" ) ;
116+ } ) ;
117+ it ( "Provides a TIME attribute" , ( ) => {
118+ expect ( STRUCTURED_ATTRS_03 . TIME ) . to . equal ( "time" ) ;
119+ } ) ;
120+ it ( "Provides a SCHEMA_URL attribute" , ( ) => {
121+ expect ( STRUCTURED_ATTRS_03 . SCHEMA_URL ) . to . equal ( "schemaurl" ) ;
122+ } ) ;
123+ it ( "Provides a CONTENT_ENCODING attribute" , ( ) => {
124+ expect ( STRUCTURED_ATTRS_03 . CONTENT_ENCONDING ) . to . equal ( "datacontentencoding" ) ;
125+ } ) ;
126+ it ( "Provides a SUBJECT attribute" , ( ) => {
127+ expect ( STRUCTURED_ATTRS_03 . SUBJECT ) . to . equal ( "subject" ) ;
128+ } ) ;
129+ it ( "Provides a DATA attribute" , ( ) => {
130+ expect ( STRUCTURED_ATTRS_03 . DATA ) . to . equal ( "data" ) ;
131+ } ) ;
132+ } ) ;
133+ describe ( "V01 binary headers constants" , ( ) => {
134+ it ( "Provides a TYPE header" , ( ) => {
135+ expect ( BINARY_HEADERS_1 . TYPE ) . to . equal ( "ce-type" ) ;
136+ } ) ;
137+ it ( "Provides a SPEC_VERSION header" , ( ) => {
138+ expect ( BINARY_HEADERS_1 . SPEC_VERSION ) . to . equal ( "ce-specversion" ) ;
139+ } ) ;
140+ it ( "Provides a SOURCE header" , ( ) => {
141+ expect ( BINARY_HEADERS_1 . SOURCE ) . to . equal ( "ce-source" ) ;
142+ } ) ;
143+ it ( "Provides an ID header" , ( ) => {
144+ expect ( BINARY_HEADERS_1 . ID ) . to . equal ( "ce-id" ) ;
145+ } ) ;
146+ it ( "Provides a TIME header" , ( ) => {
147+ expect ( BINARY_HEADERS_1 . TIME ) . to . equal ( "ce-time" ) ;
148+ } ) ;
149+ it ( "Provides a DATA_SCHEMA header" , ( ) => {
150+ expect ( BINARY_HEADERS_1 . DATA_SCHEMA ) . to . equal ( "ce-dataschema" ) ;
151+ } ) ;
152+ it ( "Provides a SUBJECT header" , ( ) => {
153+ expect ( BINARY_HEADERS_1 . SUBJECT ) . to . equal ( "ce-subject" ) ;
154+ } ) ;
155+ it ( "Provides an EXTENSIONS_PREFIX constant" , ( ) => {
156+ expect ( BINARY_HEADERS_1 . EXTENSIONS_PREFIX ) . to . equal ( "ce-" ) ;
157+ } ) ;
158+ } ) ;
159+ describe ( "V1 structured attributes constants" , ( ) => {
160+ it ( "Provides a TYPE attribute" , ( ) => {
161+ expect ( STRUCTURED_ATTRS_1 . TYPE ) . to . equal ( "type" ) ;
162+ } ) ;
163+ it ( "Provides a SPEC_VERSION attribute" , ( ) => {
164+ expect ( STRUCTURED_ATTRS_1 . SPEC_VERSION ) . to . equal ( "specversion" ) ;
165+ } ) ;
166+ it ( "Provides a SOURCE attribute" , ( ) => {
167+ expect ( STRUCTURED_ATTRS_1 . SOURCE ) . to . equal ( "source" ) ;
168+ } ) ;
169+ it ( "Provides an ID attribute" , ( ) => {
170+ expect ( STRUCTURED_ATTRS_1 . ID ) . to . equal ( "id" ) ;
171+ } ) ;
172+ it ( "Provides a TIME attribute" , ( ) => {
173+ expect ( STRUCTURED_ATTRS_1 . TIME ) . to . equal ( "time" ) ;
174+ } ) ;
175+ it ( "Provides a DATA_SCHEMA attribute" , ( ) => {
176+ expect ( STRUCTURED_ATTRS_1 . DATA_SCHEMA ) . to . equal ( "dataschema" ) ;
177+ } ) ;
178+ it ( "Provides a CONTENT_TYPE attribute" , ( ) => {
179+ expect ( STRUCTURED_ATTRS_1 . CONTENT_TYPE ) . to . equal ( "datacontenttype" ) ;
180+ } ) ;
181+ it ( "Provides a SUBJECT attribute" , ( ) => {
182+ expect ( STRUCTURED_ATTRS_1 . SUBJECT ) . to . equal ( "subject" ) ;
183+ } ) ;
184+ it ( "Provides a DATA attribute" , ( ) => {
185+ expect ( STRUCTURED_ATTRS_1 . DATA ) . to . equal ( "data" ) ;
186+ } ) ;
187+ it ( "Provides a DATA_BASE64 attribute" , ( ) => {
188+ expect ( STRUCTURED_ATTRS_1 . DATA_BASE64 ) . to . equal ( "data_base64" ) ;
189+ } ) ;
190+ } ) ;
191+ } ) ;
0 commit comments