@@ -163,6 +163,42 @@ describe('NIP-65', () => {
163163 } )
164164} )
165165
166+ describe ( 'NIP-12' , ( ) => {
167+ const geohashBase : Event = {
168+ id : 'fa4dd948576fe182f5d0e3120b9df42c83dffa1c884754d5e4d3b0a2f98a01c5' ,
169+ pubkey : 'edfa27d49d2af37ee331e1225bb6ed1912c6d999281b36d8018ad99bc3573c29' ,
170+ created_at : 1660306803 ,
171+ kind : EventKinds . TEXT_NOTE ,
172+ tags : [ ] ,
173+ content : '' ,
174+ sig : '313a9b8cd68267a51da84e292c0937d1f3686c6757c4584f50fcedad2b13fad755e6226924f79880fb5aa9de95c04231a4823981513ac9e7092bad7488282a96' ,
175+ }
176+
177+ it ( 'accepts event with valid base32 geohash tag' , ( ) => {
178+ const event = { ...geohashBase , tags : [ [ EventTags . Geohash , 'u4pruydqqvj' ] ] }
179+ const result = validateSchema ( eventSchema ) ( event )
180+ expect ( result . error ) . to . be . undefined
181+ } )
182+
183+ it ( 'rejects event with non-base32 geohash characters' , ( ) => {
184+ const event = { ...geohashBase , tags : [ [ EventTags . Geohash , 'u4pruyda' ] ] }
185+ const result = validateSchema ( eventSchema ) ( event )
186+ expect ( result . error ) . to . not . be . undefined
187+ } )
188+
189+ it ( 'rejects event with empty geohash' , ( ) => {
190+ const event = { ...geohashBase , tags : [ [ EventTags . Geohash , '' ] ] }
191+ const result = validateSchema ( eventSchema ) ( event )
192+ expect ( result . error ) . to . not . be . undefined
193+ } )
194+
195+ it ( 'rejects event with uppercase geohash' , ( ) => {
196+ const event = { ...geohashBase , tags : [ [ EventTags . Geohash , 'U4PRUYDQQVJ' ] ] }
197+ const result = validateSchema ( eventSchema ) ( event )
198+ expect ( result . error ) . to . not . be . undefined
199+ } )
200+ } )
201+
166202describe ( 'NIP-14' , ( ) => {
167203 it ( 'accepts subject tag on text note events' , ( ) => {
168204 const event : Event = {
0 commit comments