@@ -92,28 +92,92 @@ describe("Filters", function() {
9292 } ) ;
9393 } ) ;
9494
95- describe ( "data_type_filter " , function ( ) {
95+ describe ( "simple_filters " , function ( ) {
9696 beforeAll ( function ( ) {
9797 if (
9898 typeof module !== 'undefined' &&
9999 module . exports &&
100100 typeof exports !== 'undefined'
101101 ) {
102- data_type_filter = require ( '../filters/data_type_filter .js' ) ;
102+ simple_filters = require ( '../filters/simple_filters .js' ) ;
103103 }
104104 } ) ;
105105
106106 describe ( "filter_data_type" , function ( ) {
107- it ( "24bit rgb" , function ( ) {
108- expect ( data_type_filter . filter_data_type ( { "hair" :"1" , "water" :2 , "image/png" :3 , "rock" :4.0 } ) ) . toEqual ( [ 'image/png' ] ) ;
109- expect ( data_type_filter . filter_data_type ( { "application/pdf" :"file_path" , "hair" :2 , "water" :"yay" , "png" :'not a png' , "rock" :'is a rock' } ) ) . toEqual ( [ 'application/pdf' ] ) ;
110- expect ( data_type_filter . filter_data_type ( { "hair" :"this is not" , "water" :"going to return anything" , "rock" :"or is it" } ) ) . toEqual ( [ undefined ] ) ;
107+ it ( "all" , function ( ) {
108+ expect ( simple_filters . filter_data_type ( { "hair" :"1" , "water" :2 , "image/png" :3 , "rock" :4.0 } ) ) . toEqual ( [ 'image/png' ] ) ;
109+ expect ( simple_filters . filter_data_type ( { "application/pdf" :"file_path" , "hair" :2 , "water" :"yay" , "png" :'not a png' , "rock" :'is a rock' } ) ) . toEqual ( [ 'application/pdf' ] ) ;
110+ expect ( simple_filters . filter_data_type ( { "hair" :"this is not" , "water" :"going to return anything" , "rock" :"or is it" } ) ) . toEqual ( [ undefined ] ) ;
111+ } ) ;
112+ } ) ;
113+
114+ describe ( "get_metadata" , function ( ) {
115+ it ( "all" , function ( ) {
116+ var obj = {
117+ 'metadata' : {
118+ 'width' : 1 ,
119+ 'height' : 2 ,
120+ 'image/png' : {
121+ 'unconfined' : true ,
122+ 'height' : 3 ,
123+ }
124+ }
125+ }
126+
127+ expect ( simple_filters . get_metadata ( obj , 'nowhere' ) ) . toEqual ( undefined ) ;
128+ expect ( simple_filters . get_metadata ( obj , 'height' ) ) . toEqual ( 2 ) ;
129+ expect ( simple_filters . get_metadata ( obj , 'unconfined' ) ) . toEqual ( undefined ) ;
130+ expect ( simple_filters . get_metadata ( obj , 'unconfined' , 'image/png' ) ) . toEqual ( true ) ;
131+ expect ( simple_filters . get_metadata ( obj , 'width' , 'image/png' ) ) . toEqual ( 1 ) ;
132+ expect ( simple_filters . get_metadata ( obj , 'height' , 'image/png' ) ) . toEqual ( 3 ) ;
133+ } ) ;
134+ } ) ;
135+
136+ // describe("highlight_code", function() {
137+ // it("all", function() {
138+ // expect(simple_filters.highlight_code()).toEqual();
139+ // });
140+ // });
141+
142+
143+ describe ( "json_dumps" , function ( ) {
144+ it ( "all" , function ( ) {
145+ expect ( simple_filters . json_dumps ( ) ) . toEqual ( ) ;
146+ } ) ;
147+ } ) ;
148+
149+ // describe("markdown2html", function() {
150+ // it("all", function() {
151+ // expect(simple_filters.markdown2html()).toEqual();
152+ // });
153+ // });
154+
155+ describe ( "posix_path" , function ( ) {
156+ it ( "all" , function ( ) {
157+ expect ( simple_filters . posix_path ( 'path/with/forward\\and\\back' ) ) . toEqual ( 'path/with/forward/and/back' ) ;
158+ } ) ;
159+ } ) ;
160+
161+ describe ( "strip_files_prefix" , function ( ) {
162+ it ( "all" , function ( ) {
163+ expect ( simple_filters . strip_files_prefix ( '' ) ) . toEqual ( '' ) ;
164+ expect ( simple_filters . strip_files_prefix ( '/files' ) ) . toEqual ( '/files' ) ;
165+ expect ( simple_filters . strip_files_prefix ( 'test="/files"' ) ) . toEqual ( 'test="/files"' )
166+ expect ( simple_filters . strip_files_prefix ( 'My files are in `files/`' ) ) . toEqual ( 'My files are in `files/`' ) ;
167+ expect ( simple_filters . strip_files_prefix ( '<a href="files/test.html">files/test.html</a>' ) ) . toEqual ( '<a href="test.html">files/test.html</a>' ) ;
168+ expect ( simple_filters . strip_files_prefix ( '<a href="/files/test.html">files/test.html</a>' ) ) . toEqual ( '<a href="test.html">files/test.html</a>' ) ;
169+ expect ( simple_filters . strip_files_prefix ( "<a href='files/test.html'>files/test.html</a>" ) ) . toEqual ( "<a href='test.html'>files/test.html</a>" ) ;
170+ expect ( simple_filters . strip_files_prefix ( '<img src="files/url/location.gif">' ) ) . toEqual ( '<img src="url/location.gif">' ) ;
171+ expect ( simple_filters . strip_files_prefix ( '<img src="/files/url/location.gif">' ) ) . toEqual ( '<img src="url/location.gif">' ) ;
172+ expect ( simple_filters . strip_files_prefix ( 'hello![caption]' ) ) . toEqual ( 'hello![caption]' ) ;
173+ expect ( simple_filters . strip_files_prefix ( 'hello' ) ) . toEqual ( 'hello' ) ;
174+ expect ( simple_filters . strip_files_prefix ( 'hello' ) ) . toEqual ( 'hello' ) ;
175+ expect ( simple_filters . strip_files_prefix ( 'hello' ) ) . toEqual ( 'hello' ) ;
176+ expect ( simple_filters . strip_files_prefix ( 'hello' ) ) . toEqual ( 'hello' ) ;
177+ expect ( simple_filters . strip_files_prefix ( 'hello' ) ) . toEqual ( 'hello' ) ;
178+ expect ( simple_filters . strip_files_prefix ( 'hello [text](/files/url/location.gif)' ) ) . toEqual ( 'hello [text](url/location.gif)' ) ;
179+ expect ( simple_filters . strip_files_prefix ( 'hello [text space](files/url/location.gif)' ) ) . toEqual ( 'hello [text space](url/location.gif)' ) ;
111180 } ) ;
112181 } ) ;
113-
114-
115- // assert "image/png" in filter({"hair":"1", "water":2, "image/png":3, "rock":4.0})
116- // assert "application/pdf" in filter({"application/pdf":"file_path", "hair":2, "water":"yay", "png":'not a png', "rock":'is a rock'})
117- // self.assertEqual(filter({"hair":"this is not", "water":"going to return anything", "rock":"or is it"}), [])
118182 } ) ;
119183} ) ;
0 commit comments