Documentation about backward compatibility

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2018-11-09 14:43:07 -02:00
parent 2ba9916153
commit 745e6845c6
2 changed files with 29 additions and 0 deletions

View File

@ -51,6 +51,20 @@ Javascript SDK for CloudEvents
*/ */
var cloudevent01 = new Cloudevent(); var cloudevent01 = new Cloudevent();
/*
* Implemented using [Builder Design Pattern](https://en.wikipedia.org/wiki/Builder_pattern)
*/
cloudevent01
.type("com.github.pull.create")
.source("urn:event:from:myapi/resourse/123");
/*
* Backward compatibility by injecting methods from spec implementation to `Cloudevent`
* See how [here](lib/specs/spec_0_1.js#L17)
*/
cloudevent01
.eventTypeVersion("1.0");
/* /*
* Constructs an instance with: * Constructs an instance with:
* - Spec 0.2 * - Spec 0.2
@ -58,4 +72,12 @@ var cloudevent01 = new Cloudevent();
*/ */
var cloudevent02 = new Cloudevent(Cloudevent.specs['0.2']); var cloudevent02 = new Cloudevent(Cloudevent.specs['0.2']);
/*
* Different specs, but the same API.
*/
cloudevent02
.type("com.github.pull.create")
.source("urn:event:from:myapi/resourse/123");
``` ```

View File

@ -27,6 +27,13 @@ describe("CloudEvents Spec 0.1 - JavaScript SDK", () => {
}); });
}); });
describe("Backward compatibility", () => {
it("should have 'eventTypeVersion'", () => {
cloudevent.eventTypeVersion("1.0");
expect(cloudevent.format()).to.have.property('eventTypeVersion');
});
});
}); });
}); });