improved specs

This commit is contained in:
Moriz Wahl 2020-01-07 15:35:04 +01:00
parent 57ab9128ea
commit 3f37b007d7
4 changed files with 22 additions and 53 deletions

View File

@ -8,11 +8,10 @@ export default {
// see http://lucene.apache.org/core/8_3_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package.description
const myQuery = query
.replace(/\s+/g, ' ')
.replace(/[[@#:*~\\$|^\]?/"'(){}+?!,.-]/g, '')
.replace(/[[@#:*~\\$|^\]?/"'(){}+?!,.-;]/g, '')
.split(' ')
.map(s => (s.toLowerCase().match(/^(not|and|or)$/) ? '"' + s + '"' : s + '*'))
.join(' ')
// console.log(myQuery)
const postCypher = `
CALL db.index.fulltext.queryNodes('post_fulltext_search', $query)
YIELD node as resource, score
@ -73,36 +72,3 @@ export default {
},
},
}
/* order users by closest geolocation could look like this
MATCH (u1:User { id: $thisUserId })-[:IS_IN]->(l1:Location)
MATCH (u2:User)-[:IS_IN]->(l2:Location)
WHERE NOT(u2.id = $thisUserId)
AND NOT (u2.deleted = true OR u2.disabled = true
OR (u1)-[:BLOCKED]-(u2))
WITH point({longitude: l1.lng, latitude: l1.lat}) AS P1,
point({longitude: l2.lng, latitude: l2.lat}) AS P2,
u2 AS otherUsers
WITH distance(P1, P2) AS Distance,
otherUsers AS users
ORDER BY Distance
RETURN users
*/
/* This query is to test if the calculation of distances works.
See:
https://github.com/Human-Connection/Human-Connection/issues/2587
MATCH (u1:User { name: 'Huey' })-[:IS_IN]->(l1:Location)
MATCH (u2:User)-[:IS_IN]->(l2:Location)
WHERE NOT(u2.name = 'Huey')
WITH point({longitude: l1.lng, latitude: l1.lat}) AS P1,
point({longitude: l2.lng, latitude: l2.lat}) AS P2,
l1.name AS Location1, l2.name AS Location2
WITH distance(P1, P2) AS Distance,
Location1 AS Location1, Location2 AS Location2
ORDER BY Distance
RETURN Location1, Location2, Distance
*/

View File

@ -52,7 +52,7 @@ describe('SearchResources.vue', () => {
})
it('clears searchResults', () => {
expect(wrapper.find('.is-open').exists()).toBe(false)
expect(wrapper.vm.searchResults).toEqual([])
})
it('set pending to false', () => {

View File

@ -37,26 +37,24 @@ describe('SearchPost.vue', () => {
wrapper
.find('.search-post-meta')
.findAll('span')
.at(0)
.text(),
).toMatch('3')
.filter(item => item.text() === '3')
.exists(),
).toBe(true)
})
it('renders post shoutedCount', () => {
expect(
wrapper
.find('.search-post-meta')
.findAll('span')
.at(1)
.text(),
).toMatch('6')
.filter(item => item.text() === '6')
.exists(),
).toBe(true)
})
it('renders post author', () => {
expect(
wrapper
.find('.search-post-author')
.text()
.replace(/\s+-\s+/, ' '),
).toMatch('Post Author 23.08.2019')
expect(wrapper.find('.search-post-author').text()).toContain('Post Author')
})
it('renders post createdAt', () => {
expect(wrapper.find('.search-post-author').text()).toContain('23.08.2019')
})
})
})

View File

@ -7,12 +7,12 @@
<ds-flex>
<ds-flex-item>
<ds-text size="small" color="softer" class="search-post-meta">
<span style="text-align: right;">
<b>{{ option.commentsCount }}</b>
<span class="comments-count">
{{ option.commentsCount }}
<base-icon name="comments" />
</span>
<span class="post-shouted">
<b>{{ option.shoutedCount }}</b>
<span class="shouted-count">
{{ option.shoutedCount }}
<base-icon name="bullhorn" />
</span>
</ds-text>
@ -58,9 +58,14 @@ export default {
vertical-align: sub;
}
}
.post-shouted {
.shouted-count {
width: 36px;
display: inline-block;
text-align: right;
font-weight: $font-weight-bold;
}
.comments-count {
text-align: right;
font-weight: $font-weight-bold;
}
</style>