From c1292a866f3e97a9a1f258a14f558f17d3e626cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Wed, 14 Nov 2018 22:04:37 -0200 Subject: [PATCH] Unit testing for time attribute format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- test/cloudevent_spec_0_1.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/cloudevent_spec_0_1.js b/test/cloudevent_spec_0_1.js index 665a0fe..66bf5b1 100644 --- a/test/cloudevent_spec_0_1.js +++ b/test/cloudevent_spec_0_1.js @@ -1,11 +1,13 @@ var expect = require("chai").expect; var Cloudevent = require("../index.js"); -const type = "com.github.pull.create"; +const type = "com.github.pull.create"; +const source = "urn:event:from:myapi/resourse/123"; +const time = new Date(); var cloudevent = new Cloudevent() .type(type) - .source("urn:event:from:myapi/resourse/123"); + .source(source); describe("CloudEvents Spec 0.1 - JavaScript SDK", () => { @@ -45,10 +47,23 @@ describe("CloudEvents Spec 0.1 - JavaScript SDK", () => { .throw("'eventType' is invalid"); }); - it("should be a non-empty string", () => { + it("must be a non-empty string", () => { cloudevent.type(type); cloudevent.format(); }); + + it("should be prefixed with a reverse-DNS name", () => { + //TODO how to assert it? + }); + }); + + //TODO another attributes . . . + + describe("'eventTime'", () => { + it("must adhere to the format specified in RFC 3339", () => { + cloudevent.time(time); + expect(cloudevent.format()['eventTime']).to.equal(time.toISOString()); + }); }); });