Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/js/im/v2/component/search/test/ |
Upload File : |
import {SearchRecentList} from '../src/search-recent-list'; import {Type} from 'main.core'; describe('SearchRecentList', () => { const store = null; const controller = null; let restClient = null; let $Bitrix = null; let search = null; before(async () => { restClient = { callMethod: () => {} }; $Bitrix = { Data: { get() { return {store, controller}; } }, RestClient: { get() { return restClient; } } }; }); it('should be a function type', () => { assert.equal(Type.isFunction(SearchRecentList), true); }); describe('doesItemMatchQuery', () => { before(() => { search = new SearchRecentList($Bitrix); }); it('should return true for complete match', () => { const fieldsForSearch = ['ivan']; const queryWords = ['ivan']; const matchResult = search.doesItemMatchQuery(fieldsForSearch, queryWords); assert.equal(matchResult, true); }); it('should return false if query word doesn\'t match', () => { const fieldsForSearch = ['ivan']; const queryWords = ['petr']; const matchResult = search.doesItemMatchQuery(fieldsForSearch, queryWords); assert.equal(matchResult, false); }); it('should return true for one match', () => { const fieldsForSearch = ['ivan', 'smirnov', 'developer']; const queryWords = ['smi']; const matchResult = search.doesItemMatchQuery(fieldsForSearch, queryWords); assert.equal(matchResult, true); }); it('should return true for two matches', () => { const fieldsForSearch = ['ivan', 'smirnov', 'developer']; const queryWords = ['iva', 'smi']; const matchResult = search.doesItemMatchQuery(fieldsForSearch, queryWords); assert.equal(matchResult, true); }); it('should return false if any query word doesn\'t match', () => { const fieldsForSearch = ['Ivan', 'Ivanov']; const queryWords = ['Ivan', 'Smirnov']; const matchResult = search.doesItemMatchQuery(fieldsForSearch, queryWords); assert.equal(matchResult, false); }); it('should return true if all query words match with one field', () => { // trying to repeat the backend behavior const fieldsForSearch = ['Ivan', 'Smirnov']; const queryWords = ['Ivan', 'Ivan']; const matchResult = search.doesItemMatchQuery(fieldsForSearch, queryWords); assert.equal(matchResult, true); }); }); });