51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
/* global CommitsList */
|
|
|
|
//= require jquery.endless-scroll
|
|
//= require pager
|
|
//= require commits
|
|
|
|
(() => {
|
|
describe('Commits List', () => {
|
|
beforeEach(() => {
|
|
setFixtures(`
|
|
<form class="commits-search-form" action="/h5bp/html5-boilerplate/commits/master">
|
|
<input id="commits-search">
|
|
</form>
|
|
<ol id="commits-list"></ol>
|
|
`);
|
|
});
|
|
|
|
it('should be defined', () => {
|
|
expect(CommitsList).toBeDefined();
|
|
});
|
|
|
|
describe('on entering input', () => {
|
|
let ajaxSpy;
|
|
|
|
beforeEach(() => {
|
|
CommitsList.init(25);
|
|
CommitsList.searchField.val('');
|
|
spyOn(history, 'replaceState').and.stub();
|
|
ajaxSpy = spyOn(jQuery, 'ajax').and.callFake((req) => {
|
|
req.success({
|
|
data: '<li>Result</li>',
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should save the last search string', () => {
|
|
CommitsList.searchField.val('GitLab');
|
|
CommitsList.filterResults();
|
|
expect(ajaxSpy).toHaveBeenCalled();
|
|
expect(CommitsList.lastSearch).toEqual('GitLab');
|
|
});
|
|
|
|
it('should not make ajax call if the input does not change', () => {
|
|
CommitsList.filterResults();
|
|
expect(ajaxSpy).not.toHaveBeenCalled();
|
|
expect(CommitsList.lastSearch).toEqual('');
|
|
});
|
|
});
|
|
});
|
|
})();
|