diff options
author | Debanshu Kundu <debanshu.kundu@joshtechnologygroup.com> | 2017-01-20 23:11:13 +0530 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-01-20 14:41:13 -0300 |
commit | 3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4 (patch) | |
tree | b954407a03a6c0ed9836d8b14d910fc52c8dc1dc /webapp/tests/utils_get_nearest_point.test.jsx | |
parent | fefe4b70d9e69910a8e3acd6890497553b5eff2f (diff) | |
download | chat-3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4.tar.gz chat-3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4.tar.bz2 chat-3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4.zip |
#4257 Added functionality to create previews for post links using open graph data from those links. (#4890)
Diffstat (limited to 'webapp/tests/utils_get_nearest_point.test.jsx')
-rw-r--r-- | webapp/tests/utils_get_nearest_point.test.jsx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/webapp/tests/utils_get_nearest_point.test.jsx b/webapp/tests/utils_get_nearest_point.test.jsx new file mode 100644 index 000000000..b0b0a2e0e --- /dev/null +++ b/webapp/tests/utils_get_nearest_point.test.jsx @@ -0,0 +1,35 @@ +import assert from 'assert'; +import * as CommonUtils from 'utils/commons.jsx'; + +describe('CommonUtils.getNearestPoint', function() { + this.timeout(10000); + it('should return nearest point', function() { + for (const data of [ + { + points: [{x: 30, y: 40}, {x: 50, y: 50}, {x: 100, y: 2}, {x: 500, y: 200}, {x: 110, y: 20}, {x: 10, y: 20}], + pivotPoint: {x: 10, y: 20}, + nearestPoint: {x: 10, y: 20}, + nearestPointLte: {x: 10, y: 20} + }, + { + points: [{x: 50, y: 50}, {x: 100, y: 2}, {x: 500, y: 200}, {x: 110, y: 20}, {x: 100, y: 90}, {x: 30, y: 40}], + pivotPoint: {x: 10, y: 20}, + nearestPoint: {x: 30, y: 40}, + nearestPointLte: {} + }, + { + points: [{x: 50, y: 50}, {x: 1, y: 1}, {x: 15, y: 25}, {x: 100, y: 2}, {x: 500, y: 200}, {x: 110, y: 20}], + pivotPoint: {x: 10, y: 20}, + nearestPoint: {x: 15, y: 25}, + nearestPointLte: {x: 1, y: 1} + } + ]) { + const nearestPointData = CommonUtils.getNearestPoint(data.pivotPoint, data.points); + + assert.equal(nearestPointData.nearestPoint.x, data.nearestPoint.x); + assert.equal(nearestPointData.nearestPoint.y, data.nearestPoint.y); + assert.equal(nearestPointData.nearestPointLte.x, data.nearestPointLte.x); + assert.equal(nearestPointData.nearestPointLte.y, data.nearestPointLte.y); + } + }); +}); |