blob: 59c428fb3fa8a867a83af0eaf358a89b9df38ab3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import { nextTick } from 'vue';
import { setHTMLFixture } from 'helpers/fixtures';
import RecentSearchesRoot from '~/filtered_search/recent_searches_root';
const containerId = 'test-container';
const dropdownElementId = 'test-dropdown-element';
describe('RecentSearchesRoot', () => {
describe('render', () => {
let recentSearchesRootMockInstance;
let vm;
let containerEl;
beforeEach(async () => {
setHTMLFixture(`
<div id="${containerId}">
<div id="${dropdownElementId}"></div>
</div>
`);
containerEl = document.getElementById(containerId);
recentSearchesRootMockInstance = {
store: {
state: {
recentSearches: ['foo', 'bar', 'qux'],
isLocalStorageAvailable: true,
allowedKeys: ['test'],
},
},
wrapperElement: document.getElementById(dropdownElementId),
};
RecentSearchesRoot.prototype.render.call(recentSearchesRootMockInstance);
vm = recentSearchesRootMockInstance.vm;
await nextTick();
});
afterEach(() => {
vm.$destroy();
});
it('should render the recent searches', () => {
const { recentSearches } = recentSearchesRootMockInstance.store.state;
recentSearches.forEach((recentSearch) => {
expect(containerEl.textContent).toContain(recentSearch);
});
});
});
});
|