From a450f0cf265b87b69661717b4b459df28cb83a0a Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 19 Apr 2016 10:13:50 -0700 Subject: [PATCH] feat: we should be pulling annotations for a specific package (#4) --- index.js | 3 ++- test.js | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index bbb0b4b..6fc02bc 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,8 @@ var Mustache = require('mustache') function AnnotationPoller (opts) { this.pollInterval = opts.pollInterval || 3000 - this.endpoint = '/api/v1/annotations' + this.pkg = opts.pkg // what package should we load annotations for? + this.endpoint = '/api/v1/annotations/' + this.pkg this.annotations = {} this.template = '
  • {{description}}{{external-link-text}}
  • ' this.addonSelector = '#npm-addon-box' diff --git a/test.js b/test.js index 1c3d500..fede2b6 100644 --- a/test.js +++ b/test.js @@ -3,7 +3,8 @@ require('jsdom-global')() var annotationPoller = require('./') -var endpoint = '/api/v1/annotations' +var pkg = encodeURIComponent('cool module') +var endpoint = '/api/v1/annotations/' + pkg var $ = require('jquery') require('jquery-mockjax')($) @@ -32,7 +33,7 @@ describe('annotation-poller', function () { }] }) - var poller = annotationPoller({pollInterval: 50}) + var poller = annotationPoller({pollInterval: 50, pkg: pkg}) poller.start(function () { poller.annotations['abc-123-abc'].status = 'warn' poller.annotations['abc-123-abc'].description = 'foo security integration' @@ -55,7 +56,7 @@ describe('annotation-poller', function () { }] }) - var poller = annotationPoller({pollInterval: 50}) + var poller = annotationPoller({pollInterval: 50, pkg: pkg}) poller.start(function () { $('ul li').length.should.equal(1) $('ul li').text().should.match(/my awesome integration/) @@ -78,7 +79,7 @@ describe('annotation-poller', function () { }] }) - var poller = annotationPoller({pollInterval: 50}) + var poller = annotationPoller({pollInterval: 50, pkg: pkg}) poller.start(function () { $.mockjax.clear() $.mockjax({ @@ -117,7 +118,7 @@ describe('annotation-poller', function () { }] }) - var poller = annotationPoller({pollInterval: 50}) + var poller = annotationPoller({pollInterval: 50, pkg: pkg}) poller.start(function () { $.mockjax.clear() $.mockjax({