mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	more tests & fixes
This commit is contained in:
		
							parent
							
								
									a1a744bb00
								
							
						
					
					
						commit
						c753f228ac
					
				@ -492,6 +492,24 @@ describe("Search", () => {
 | 
			
		||||
        expect(noteCache.notes[searchResults[1].noteId].title).toEqual("Ukraine");
 | 
			
		||||
        expect(noteCache.notes[searchResults[2].noteId].title).toEqual("Italy");
 | 
			
		||||
        expect(noteCache.notes[searchResults[3].noteId].title).toEqual("Austria");
 | 
			
		||||
 | 
			
		||||
        searchResults = await searchService.findNotesWithQuery('# note.parents.title = Europe orderBy note.labels.capital DESC', parsingContext);
 | 
			
		||||
        expect(searchResults.length).toEqual(4);
 | 
			
		||||
        expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Austria");
 | 
			
		||||
        expect(noteCache.notes[searchResults[1].noteId].title).toEqual("Italy");
 | 
			
		||||
        expect(noteCache.notes[searchResults[2].noteId].title).toEqual("Ukraine");
 | 
			
		||||
        expect(noteCache.notes[searchResults[3].noteId].title).toEqual("Slovakia");
 | 
			
		||||
 | 
			
		||||
        searchResults = await searchService.findNotesWithQuery('# note.parents.title = Europe orderBy note.labels.capital DESC limit 2', parsingContext);
 | 
			
		||||
        expect(searchResults.length).toEqual(2);
 | 
			
		||||
        expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Austria");
 | 
			
		||||
        expect(noteCache.notes[searchResults[1].noteId].title).toEqual("Italy");
 | 
			
		||||
 | 
			
		||||
        searchResults = await searchService.findNotesWithQuery('# note.parents.title = Europe orderBy #capital DESC limit 0', parsingContext);
 | 
			
		||||
        expect(searchResults.length).toEqual(0);
 | 
			
		||||
 | 
			
		||||
        searchResults = await searchService.findNotesWithQuery('# note.parents.title = Europe orderBy #capital DESC limit 1000', parsingContext);
 | 
			
		||||
        expect(searchResults.length).toEqual(4);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // FIXME: test what happens when we order without any filter criteria
 | 
			
		||||
 | 
			
		||||
@ -44,7 +44,7 @@ class OrderByAndLimitExp extends Expression {
 | 
			
		||||
            return 0;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        if (this.limit) {
 | 
			
		||||
        if (this.limit >= 0) {
 | 
			
		||||
            notes = notes.slice(0, this.limit);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -170,8 +170,8 @@ function getExpression(tokens, parsingContext, level = 0) {
 | 
			
		||||
                    i++;
 | 
			
		||||
                } while (tokens[i] === '.');
 | 
			
		||||
 | 
			
		||||
                if (["asc", "desc"].includes(tokens[i + 1])) {
 | 
			
		||||
                    direction = tokens[i + 1];
 | 
			
		||||
                if (["asc", "desc"].includes(tokens[i])) {
 | 
			
		||||
                    direction = tokens[i];
 | 
			
		||||
                    i++;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user