feat(ObjectSorter): now sorts objects by likability

This commit is contained in:
2018-08-19 20:52:52 +02:00
parent fdf9ec6358
commit dc856dd5c7
4 changed files with 56 additions and 8 deletions

View File

@ -14,11 +14,30 @@ tap.test('should create an instance of Smartfuzzy', async () => {
});
tap.test('should compute a score', async () => {
testSmartfuzzy.getChangeScoreForString('Apple');
const result = testSmartfuzzy.getChangeScoreForString('Apple');
console.log(result);
});
tap.test('should get closest match', async () => {
testSmartfuzzy.getClosestMatchForString('Apple');
const result = testSmartfuzzy.getClosestMatchForString('Apple');
console.log(result);
});
tap.test('should sort objects', async () => {
class Car {
constructor(public brand: string) {}
}
let testObjectSorter: smartfuzzy.ObjectSorter<Car>;
testObjectSorter = new smartfuzzy.ObjectSorter([
new Car('BMW'),
new Car('Mercedes Benz'),
new Car('Volvo')
]);
const result = testObjectSorter.sort('Volvo', ['brand']);
console.log(result);
});
tap.start();