Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
feat: we should be pulling annotations for a specific package (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Apr 19, 2016
1 parent d8fe372 commit a450f0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -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 = '<li id="annotation-{{id}}" style="{{status}}" data-fingerprint={{fingerprint}}><span>{{description}}</span><a href="{{{external-link}}}">{{external-link-text}}</a></li>'
this.addonSelector = '#npm-addon-box'
Expand Down
11 changes: 6 additions & 5 deletions test.js
Expand Up @@ -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')($)
Expand Down Expand Up @@ -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'
Expand All @@ -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/)
Expand All @@ -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({
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit a450f0c

Please sign in to comment.