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

feat: we should be polling for annotations specific to a package #4

Merged
merged 1 commit into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
require('jsdom-global')()

var annotationPoller = require('./')
var endpoint = '/api/v1/annotations'
var pkg = encodeURIComponent('cool module')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can packages have whitespace in their names? I was not aware of that. :)

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