File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ var Filter = exports.Filter = function Filter(options) {
22
22
this . filters = [ ] ;
23
23
this . current = 0 ;
24
24
25
- for ( var i = 0 , len = this . options . filters ; i < len ; i ++ ) {
25
+ for ( var i = 0 , len = this . options . filters . length ; i < len ; i ++ ) {
26
26
var filter = this . options . filters [ i ] ;
27
27
this . addFilter ( filter ) ;
28
28
}
Original file line number Diff line number Diff line change @@ -70,6 +70,44 @@ describe('ui.filter.Filter', function () {
70
70
} ) ;
71
71
} ) ;
72
72
73
+ describe ( "passing filters to constructor" , function ( ) {
74
+ var testFilter = null ;
75
+
76
+ beforeEach ( function ( ) {
77
+ testFilter = {
78
+ label : 'Tag' ,
79
+ property : 'tags'
80
+ } ;
81
+ plugin = new filter . Filter ( {
82
+ filterElement : element ,
83
+ filters : [ testFilter ] ,
84
+ addAnnotationFilter : false
85
+ } ) ;
86
+ } ) ;
87
+
88
+ it ( "should add a filter object to Filter#plugins" , function ( ) {
89
+ assert . ok ( plugin . filters [ 0 ] ) ;
90
+ } ) ;
91
+
92
+ it ( "should append the html to Filter#toolbar" , function ( ) {
93
+ testFilter = plugin . filters [ 0 ] ;
94
+ assert . equal ( testFilter . element [ 0 ] , plugin . element . find ( '#annotator-filter-tags' ) . parent ( ) [ 0 ] ) ;
95
+ } ) ;
96
+
97
+ it ( "should store the filter in the elements data store under 'filter'" , function ( ) {
98
+ testFilter = plugin . filters [ 0 ] ;
99
+ assert . equal ( testFilter . element . data ( 'filter' ) , plugin . filters [ 0 ] ) ;
100
+ } ) ;
101
+
102
+ it ( "should not add a filter for a property that has already been loaded" , function ( ) {
103
+ plugin . addFilter ( {
104
+ label : 'Tag' ,
105
+ property : 'tags'
106
+ } ) ;
107
+ assert . lengthOf ( plugin . filters , 1 ) ;
108
+ } ) ;
109
+ } ) ;
110
+
73
111
describe ( "updateFilter" , function ( ) {
74
112
var testFilter = null ,
75
113
annotations = null ;
You can’t perform that action at this time.
0 commit comments