File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1562,6 +1562,11 @@ fake.registerWebservice('https://api.ideal-postcodes.co.uk/v1/keys/idklicensees'
15621562 return ( data . licensee === "testlicensee" ) ? keyCheckPass : uncataloguedError ;
15631563} ) ;
15641564
1565+ // Mocked Licensees Requests
1566+ fake . registerWebservice ( 'https://api.ideal-postcodes.co.uk/v1/keys/iddlicensees' , function ( data ) {
1567+ return ( data . licensee === "testlicensee" ) ? keyCheckPass : keyCheckFail ;
1568+ } ) ;
1569+
15651570fake . registerWebservice ( 'https://api.ideal-postcodes.co.uk/v1/postcodes/id11li' , function ( data ) {
15661571 return ( data . licensee === "testlicensee" ) ? testPostcodeResult : uncataloguedError ;
15671572} ) ;
Original file line number Diff line number Diff line change 824824
825825 // Check if key is usable if necessary
826826 if ( options . check_key ) {
827- $ . idealPostcodes . checkKey ( {
828- api_key : options . api_key
829- } , initPlugin , failedKeyCheck ) ;
827+ var keyOptions = { api_key : options . api_key } ;
828+ if ( options . licensee ) {
829+ keyOptions . licensee = options . licensee ;
830+ }
831+ $ . idealPostcodes . checkKey ( keyOptions , initPlugin , failedKeyCheck ) ;
830832 } else {
831833 initPlugin ( ) ;
832834 }
Original file line number Diff line number Diff line change 185185 equal ( $lookup_button . length , 0 , "there is no button" ) ;
186186 } ) ;
187187
188+ module ( "Sublicensee: Pre-initialisation check" , {
189+ setup : function ( ) {
190+ stop ( ) ;
191+ var startTests = function ( ) {
192+ $input_field = $ ( "#" + defaults . input_id ) ;
193+ $lookup_button = $ ( "#" + defaults . button_id ) ;
194+ start ( ) ;
195+ } ;
196+ $ ( "#postcode_lookup_field" ) . setupPostcodeLookup ( {
197+ // Test key which will return false
198+ api_key : "iddlicensees" ,
199+ licensee : "testlicensee" ,
200+ check_key : true ,
201+ disable_interval : 0 ,
202+ onFailedCheck : startTests ,
203+ onLoaded : startTests
204+ } ) ;
205+ }
206+ } ) ;
207+
208+ test ( "has postcode lookup tools setup" , 2 , function ( ) {
209+ equal ( $input_field . length , 1 , "there is postcode input" ) ;
210+ equal ( $lookup_button . length , 1 , "there is button" ) ;
211+ } ) ;
212+
188213} ( jQuery ) ) ;
You can’t perform that action at this time.
0 commit comments