|
| 1 | +const threePoints = require('./three_points'); |
| 2 | + |
| 3 | +describe('threePoints()', () => { |
| 4 | + test('correctly returns side of point relative to line', () => { |
| 5 | + expect(threePoints(['(1,1)', '(3,3)', '(2,0)'])).toBe('right'); |
| 6 | + |
| 7 | + expect(threePoints(['(0,-3)', '(-2,0)', '(0,0)'])).toBe('right'); |
| 8 | + |
| 9 | + expect(threePoints(['(0,0)', '(0,5)', '(0,2)'])).toBe('neither'); |
| 10 | + }); |
| 11 | + |
| 12 | + test('passes Coderbyte.com tests', () => { |
| 13 | + expect(threePoints(['(1,1)', '(3,3)', '(2,0)'])).toBe('right'); |
| 14 | + |
| 15 | + expect(threePoints(['(0,-3)', '(-2,0)', '(0,0)'])).toBe('right'); |
| 16 | + |
| 17 | + expect(threePoints(['(0,0)', '(0,5)', '(0,2)'])).toBe('neither'); |
| 18 | + |
| 19 | + expect(threePoints(['(0,0)', '(0,5)', '(-2,2)'])).toBe('left'); |
| 20 | + |
| 21 | + expect(threePoints(['(0,0)', '(0,100)', '(-200,5)'])).toBe('left'); |
| 22 | + |
| 23 | + expect(threePoints(['(-3,0)', '(0,1)', '(-1,0)'])).toBe('right'); |
| 24 | + |
| 25 | + expect(threePoints(['(0,1)', '(-3,0)', '(-1,0)'])).toBe('left'); |
| 26 | + |
| 27 | + expect(threePoints(['(0,5)', '(0,-5)', '(1,1)'])).toBe('left'); |
| 28 | + |
| 29 | + // TODO: Fix to pass this test |
| 30 | + expect(threePoints(['(100,100)', '(-1,-1)', '(5,1)'])).toBe('left'); |
| 31 | + |
| 32 | + expect(threePoints(['(5000,5001)', '(-5001,-5000)', '(0,601)'])).toBe( |
| 33 | + 'right' |
| 34 | + ); |
| 35 | + }); |
| 36 | +}); |
0 commit comments