Skip to content

Commit f324cce

Browse files
zachallaunjosevalim
authored andcommitted
Add test for section suggestions
1 parent 8ba248c commit f324cce

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

assets/test/autocomplete/suggestions.spec.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ describe('getSuggestions', () => {
1919
{
2020
id: 'Kernel',
2121
title: 'Kernel',
22+
sections: [
23+
{id: 'The standard library', anchor: 'module-the-standard-library'},
24+
{id: 'Guards', anchor: 'module-guards'}
25+
],
2226
nodeGroups: [
2327
{
2428
key: 'functions',
@@ -54,7 +58,20 @@ describe('getSuggestions', () => {
5458
}
5559
],
5660
tasks: [{id: 'phx.server', title: 'phx.server'}],
57-
extras: [{id: 'api-reference', title: 'API Reference'}]
61+
extras: [
62+
{
63+
id: 'api-reference',
64+
title: 'API Reference'
65+
},
66+
{
67+
id: 'library-guidelines',
68+
title: 'Library Guidelines',
69+
headers: [
70+
{id: 'Getting started', anchor: 'getting-started'},
71+
{id: 'Publishing', anchor: 'publishing'}
72+
]
73+
}
74+
]
5875
}
5976
})
6077

@@ -67,6 +84,11 @@ describe('getSuggestions', () => {
6784
expect(getSuggestions('My exception').length).to.eql(1)
6885
})
6986

87+
it('returns matching sections of modules and extras', () => {
88+
expect(getSuggestions('Getting').length).to.eql(1)
89+
expect(getSuggestions('Gua').length).to.eql(1)
90+
})
91+
7092
it('returns matching functions, callbacks and types', () => {
7193
expect(getSuggestions('get_by').length).to.eql(1)
7294
expect(getSuggestions('fetch').length).to.eql(1)
@@ -110,7 +132,7 @@ describe('getSuggestions', () => {
110132
})
111133

112134
it('sorts results, putting closer matches at the top', () => {
113-
let results = getSuggestions('insert')
135+
const results = getSuggestions('insert')
114136
expect(results[0].title).to.eql('<em>insert</em>/2')
115137
expect(results[1].title).to.eql('<em>insert</em>_all/3')
116138
})

0 commit comments

Comments
 (0)