|
| 1 | +import TimeUnit from '../../../data/TimeUnit'; |
| 2 | + |
| 3 | +import build from './build'; |
| 4 | + |
| 5 | +jest.unmock('convert-units'); |
| 6 | + |
| 7 | +describe('#build', () => { |
| 8 | + const location = { name: 'foobar' }; |
| 9 | + |
| 10 | + // both tests use emojis and assumes process.platform = darwin |
| 11 | + // apologies in advance if this causes problems |
| 12 | + |
| 13 | + it('builds table for products that do not share same formatted duration', () => { |
| 14 | + const estimates = [ |
| 15 | + { |
| 16 | + estimatedDuration: { length: 120, unit: TimeUnit.SECOND }, |
| 17 | + productName: 'first product', |
| 18 | + }, |
| 19 | + { |
| 20 | + estimatedDuration: { length: 60, unit: TimeUnit.SECOND }, |
| 21 | + productName: 'second product', |
| 22 | + }, |
| 23 | + { |
| 24 | + estimatedDuration: { length: 0, unit: TimeUnit.SECOND }, |
| 25 | + productName: 'third product', |
| 26 | + }, |
| 27 | + ]; |
| 28 | + const expected = '\u001b[90mβββββββββββββββββββββββββββ\u001b[39m\n\u001b[90mβ\u001b[39m π foobar \u001b[90mβ\u001b[39m\n\u001b[90mβββββββββ\u001b[39m\u001b[90mβ¬βββββββββββββββββ€\u001b[39m\n\u001b[90mβ\u001b[39m β³ \u001b[90mβ\u001b[39m π \u001b[90mβ\u001b[39m\n\u001b[90mβββββββββ\u001b[39m\u001b[90mβΌβββββββββββββββββ€\u001b[39m\n\u001b[90mβ\u001b[39m 0 sec. \u001b[90mβ\u001b[39m third product \u001b[90mβ\u001b[39m\n\u001b[90mβββββββββ\u001b[39m\u001b[90mβΌβββββββββββββββββ€\u001b[39m\n\u001b[90mβ\u001b[39m 1 min. \u001b[90mβ\u001b[39m second product \u001b[90mβ\u001b[39m\n\u001b[90mβββββββββ\u001b[39m\u001b[90mβΌβββββββββββββββββ€\u001b[39m\n\u001b[90mβ\u001b[39m 2 min. \u001b[90mβ\u001b[39m first product \u001b[90mβ\u001b[39m\n\u001b[90mβββββββββ\u001b[39m\u001b[90mβ΄βββββββββββββββββ\u001b[39m'; |
| 29 | + expect(build({ estimates, location })).toEqual(expected); |
| 30 | + }); |
| 31 | + |
| 32 | + it('builds table for products that do share same formatted duration', () => { |
| 33 | + const estimates = [ |
| 34 | + { |
| 35 | + estimatedDuration: { length: 120, unit: TimeUnit.SECOND }, |
| 36 | + productName: 'first product', |
| 37 | + }, |
| 38 | + { |
| 39 | + estimatedDuration: { length: 120, unit: TimeUnit.SECOND }, |
| 40 | + productName: 'second product', |
| 41 | + }, |
| 42 | + { |
| 43 | + estimatedDuration: { length: 120, unit: TimeUnit.SECOND }, |
| 44 | + productName: 'third product', |
| 45 | + }, |
| 46 | + ]; |
| 47 | + const expected = '\u001b[90mβββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\u001b[39m\n\u001b[90mβ\u001b[39m π foobar \u001b[90mβ\u001b[39m\n\u001b[90mβββββββββ\u001b[39m\u001b[90mβ¬βββββββββββββββββββββββββββββββββββββββββββββββ€\u001b[39m\n\u001b[90mβ\u001b[39m β³ \u001b[90mβ\u001b[39m π \u001b[90mβ\u001b[39m\n\u001b[90mβββββββββ\u001b[39m\u001b[90mβΌβββββββββββββββββββββββββββββββββββββββββββββββ€\u001b[39m\n\u001b[90mβ\u001b[39m 2 min. \u001b[90mβ\u001b[39m first product, second product, third product \u001b[90mβ\u001b[39m\n\u001b[90mβββββββββ\u001b[39m\u001b[90mβ΄βββββββββββββββββββββββββββββββββββββββββββββββ\u001b[39m'; |
| 48 | + expect(build({ estimates, location })).toEqual(expected); |
| 49 | + }); |
| 50 | +}); |
0 commit comments