smartfuzzy/test/test.articlesearch.ts

35 lines
992 B
TypeScript
Raw Normal View History

2021-10-03 15:12:02 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
import * as tsclass from '@tsclass/tsclass';
import * as smartfuzzy from '../ts/index';
tap.test('should sort objects', async () => {
const articleArray: tsclass.content.IArticle[] = [
{
title: 'Berlin has a ambivalent history',
content: 'it is known that Berlin has an interesting history',
author: null,
tags: ['city', 'Europe', 'hello'],
timestamp: Date.now(),
featuredImageUrl: null,
url: null
},
{
title: 'Washington is a great city',
content: 'it is known that Washington is one of the greatest cities in the world',
author: null,
tags: ['city', 'USA', 'hello'],
timestamp: Date.now(),
featuredImageUrl: null,
url: null
}
];
const testArticleSearch = new smartfuzzy.ArticleSearch(articleArray);
const result = await testArticleSearch.search('USA');
console.log(result);
2021-10-03 15:24:17 +00:00
console.log(result[0].matches)
2021-10-03 15:12:02 +00:00
});
tap.start();