it("should add the plugins to the annotator instance", function () {
     var instance = window._annotator.instance;
     assert(hasPlugin(instance, 'Auth'));
     assert(hasPlugin(instance, 'Store'));
     assert(hasPlugin(instance, 'AnnotateItPermissions'));
     assert(hasPlugin(instance, 'Unsupported'));
 });
 it("should display a notification if the bookmarklet has loaded", function () {
     window._annotator.instance = {};
     window._annotator.Annotator = {
         showNotification: sinon.spy()
     };
     bookmarklet.init();
     assert(window._annotator.Annotator.showNotification.called);
 });
Beispiel #3
0
 it('sets a default onDelete handler that calls the storage delete function', function () {
     viewer.standalone().start(mockApp);
     var passedOptions = viewer.Viewer.firstCall.args[0];
     assert(sinon.match.has('onDelete').test(passedOptions));
     passedOptions.onDelete({
         text: 'foo'
     });
     sinon.assert.calledWith(mockApp.annotations["delete"], {
         text: 'foo'
     });
 });
Beispiel #4
0
 it('sets a default permitDelete handler that consults the authorization policy', function () {
     viewer.standalone().start(mockApp);
     var passedOptions = viewer.Viewer.firstCall.args[0];
     assert(sinon.match.has('permitDelete').test(passedOptions));
     passedOptions.permitDelete({text: 'foo'});
     sinon.assert.calledWith(
         mockAuthz.permits,
         'delete',
         {text: 'foo'},
         'alice'
     );
 });
Beispiel #5
0
 it('should contain an delete button', function () {
     v.load([{text: "Anteaters with torches"}]);
     assert(v.element.find('.annotator-delete'));
 });
Beispiel #6
0
 it('should add the plugin label to the field element', function () {
     assert($(elem).html().indexOf('Example field') >= 0);
 });
 it("should display a notification telling the user the page is loading", function () {
     bookmarklet.init();
     assert(bookmarklet.notification.show.called);
 });
Beispiel #8
0
 it("should invert the widget if it does not fit horizontally or vertically", function () {
     assert(w.invertX.calledOnce);
     assert(w.invertY.calledOnce);
 });
Beispiel #9
0
 it("should trigger the blur event", function () {
     assert(mockjQuery.blur.calledOnce);
 });
Beispiel #10
0
 it("should call Filter#filterHighlights()", function () {
     plugin.updateFilter(testFilter);
     assert(plugin.filterHighlights.calledOnce);
 });
 it("should retrieve user and permissions from config", function () {
     bookmarklet.annotateItPermissionsOptions();
     assert(bookmarklet.config.calledWith("annotateItPermissions"));
 });
 it("should display a loaded notification", function () {
     assert(bookmarklet.notification.message.called);
 });
 it("should add the tags plugin if options.tags is true", function () {
     var instance = window._annotator.instance;
     assert(hasPlugin(instance, 'Tags'));
 });
 bookmarklet.load(function () {
     assert(bookmarklet._injectElement.calledWith('body'));
     done();
 });
Beispiel #15
0
 it("should invert the widget if it does not fit vertically and the window is scrolled", function () {
     assert.isFalse(w.invertX.called);
     assert(w.invertY.calledOnce);
 });
 it("should retrieve store prefix from config", function () {
     bookmarklet.storeOptions();
     assert(bookmarklet.config.calledWith("store.prefix"));
 });
 it("should have set a uri property", function () {
     var uri = bookmarklet.storeOptions().annotationData.uri;
     assert(uri);
 });
Beispiel #18
0
 it("should animate the scrollbar to the highlight offset", function () {
     plugin._scrollToHighlight({});
     assert(mockjQuery.offset.calledOnce);
     assert(mockjQuery.animate.calledOnce);
 });
 return it("should call notification.message", function () {
     notification.show("hello", "red");
     return assert(notification.message.calledWith("hello", "red"));
 });
Beispiel #20
0
 it("should trigger the keyup event", function () {
     assert(mockjQuery.keyup.calledOnce);
 });
Beispiel #21
0
 it("should reset the widget each time", function () {
     assert(w.resetOrientation.calledOnce);
     assert.isFalse(w.invertX.called);
     assert.isFalse(w.invertY.called);
 });