describe('load', function() { it_n('should start loading results if preload:"focus"', function(done) { var calls_focus = 0; var calls_load = 0; var test = setup_test('AB_Single',{ preload: 'focus', load: function(query, load_cb) { calls_load++; assert.equal(query, ''); setTimeout(function() { load_cb([{value: 'c', text: 'C'}]); }); } }); test.instance.on('focus', function() { calls_focus++; }); click(test.instance.control, function() { setTimeout(function() { assert.equal(calls_focus, 1); assert.equal(calls_load, 1); done(); }, 300); }); }); it_n('should start loading if preload:true', function(done) { setup_test('AB_Single',{ preload: true, load: function(query, load_cb) { assert.equal(query, ''); load_cb([{value: 'c', text: 'C'}]); done(); } }); }); it_n('should not show no_results message while/after loading', function(done) { var test = setup_test('',{ load: function(query, load_cb) { if ( query.length < 3 ) return load_cb(); }, render: { no_results: (data,escape) => { if( data.input.length < 3) return; return '
No results found
'; }, loading: (data,escape) => { if( data.input.length < 3 ) return; return '
'; }, } }); syn.type('a', test.instance.control_input,function(){ setTimeout(function(){ assert.equal(test.instance.isOpen, false); done(); },100); }); }); });