Improve AnnotationSync test names

Rename all the tests to better reflect what they actually test.

Mostly replacing broadcast local event bus publisher proxying with
"calls function", plus a couple of other clarifications.

Before:

  AnnotationSync
    channel event handlers
      the "deleteAnnotation" event
        ✓ broadcasts the "annotationDeleted" event over the local event bus
        ✓ calls back with a formatted annotation
        ✓ removes an existing entry from the cache before the event is triggered
        ✓ removes the annotation from the cache
      the "loadAnnotations" event
        ✓ publishes the "annotationsLoaded" event
    event handlers
      the "beforeAnnotationCreated" event
        ✓ proxies the event over the bridge
        ✓ returns early if the annotation has a tag

After:

  AnnotationSync
    #constructor
      when "deleteAnnotation" is published
        ✓ calls emit("annotationDeleted")
        ✓ calls the 'deleteAnnotation' event's callback function
        ✓ deletes any existing annotation from its cache before calling emit
        ✓ deletes any existing annotation from its cache
      when "loadAnnotations" is published
        ✓ calls emit("annotationsLoaded")
      when "beforeAnnotationCreated" is emitted
        ✓ calls bridge.call() passing the event
        if the annotation has a $tag
          ✓ does not call bridge.call()
parent 90535d22
......@@ -47,7 +47,7 @@ describe('AnnotationSync', function() {
describe('#constructor', function() {
context('when "deleteAnnotation" is published', function() {
it('broadcasts the "annotationDeleted" event over the local event bus', function() {
it('calls emit("annotationDeleted")', function() {
var ann = {id: 1, $tag: 'tag1'};
var eventStub = sinon.stub();
options.on('annotationDeleted', eventStub);
......@@ -58,7 +58,7 @@ describe('AnnotationSync', function() {
assert.calledWith(eventStub, ann);
});
it('calls back with a formatted annotation', function(done) {
it("calls the 'deleteAnnotation' event's callback function", function(done) {
var ann = {id: 1, $tag: 'tag1'};
var callback = function(err, ret) {
assert.isNull(err);
......@@ -70,7 +70,7 @@ describe('AnnotationSync', function() {
publish('deleteAnnotation', {msg: ann}, callback);
});
it('removes an existing entry from the cache before the event is triggered', function() {
it('deletes any existing annotation from its cache before calling emit', function() {
var ann = {id: 1, $tag: 'tag1'};
var annSync = createAnnotationSync();
annSync.cache.tag1 = ann;
......@@ -79,7 +79,7 @@ describe('AnnotationSync', function() {
publish('deleteAnnotation', {msg: ann}, function() {});
});
it('removes the annotation from the cache', function() {
it('deletes any existing annotation from its cache', function() {
var ann = {id: 1, $tag: 'tag1'};
var annSync = createAnnotationSync();
annSync.cache.tag1 = ann;
......@@ -91,7 +91,7 @@ describe('AnnotationSync', function() {
});
context('when "loadAnnotations" is published', function() {
it('publishes the "annotationsLoaded" event', function() {
it('calls emit("annotationsLoaded")', function() {
var annotations = [
{id: 1, $tag: 'tag1'},
{id: 2, $tag: 'tag2'},
......@@ -113,7 +113,7 @@ describe('AnnotationSync', function() {
});
context('when "beforeAnnotationCreated" is emitted', function() {
it('proxies the event over the bridge', function() {
it('calls bridge.call() passing the event', function() {
var ann = {id: 1};
createAnnotationSync();
......@@ -125,13 +125,15 @@ describe('AnnotationSync', function() {
sinon.match.func);
});
it('returns early if the annotation has a tag', function() {
var ann = {id: 1, $tag: 'tag1'};
createAnnotationSync();
context('if the annotation has a $tag', function() {
it('does not call bridge.call()', function() {
var ann = {id: 1, $tag: 'tag1'};
createAnnotationSync();
options.emit('beforeAnnotationCreated', ann);
options.emit('beforeAnnotationCreated', ann);
assert.notCalled(fakeBridge.call);
assert.notCalled(fakeBridge.call);
});
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment