dyaskur /
google-chat-shuffler
| 1 | import { |
||
| 2 | extractConfig, |
||
| 3 | extractMessageAndConfig, |
||
| 4 | extractMessageByDoubleQuote, |
||
| 5 | getRandomWinners, |
||
| 6 | } from '../helpers/utils.js'; |
||
| 7 | |||
| 8 | test('get the winner', () => { |
||
| 9 | const names = ['Ibrahim', 'Isa', 'Moses', 'Ismail']; |
||
| 10 | |||
| 11 | const winners = getRandomWinners(names); |
||
| 12 | |||
| 13 | expect(winners.length).toEqual(1); |
||
| 14 | |||
| 15 | const winners2 = getRandomWinners(names, 2); |
||
| 16 | |||
| 17 | expect(winners2.length).toEqual(2); |
||
| 18 | }); |
||
| 19 | |||
| 20 | const dataSet = [ |
||
| 21 | [ |
||
| 22 | '"anu kae" "super" "sekali kae lo"', [ |
||
| 23 | 'anu kae', 'super', 'sekali kae lo', |
||
| 24 | ]], |
||
| 25 | [ |
||
| 26 | '"Indonesia" "Malaysia" Bali', ['Indonesia', 'Malaysia'], |
||
| 27 | ], |
||
| 28 | [ |
||
| 29 | 'nganu kae', [], |
||
| 30 | ], |
||
| 31 | [ |
||
| 32 | 'z', [], |
||
| 33 | ], |
||
| 34 | [ |
||
| 35 | '', [], |
||
| 36 | ], |
||
| 37 | ]; |
||
| 38 | it.each(dataSet)('Extract message using inside quote only', (input, expectedValue) => { |
||
|
0 ignored issues
–
show
|
|||
| 39 | const extractedStrings = extractMessageByDoubleQuote(input); |
||
| 40 | |||
| 41 | expect(extractedStrings).toEqual(expectedValue); |
||
| 42 | }); |
||
| 43 | |||
| 44 | const dataSet2 = [ |
||
| 45 | [ |
||
| 46 | '"anu kae" "super" "sekali kae lo"', [ |
||
| 47 | 'anu kae', 'super', 'sekali kae lo', |
||
| 48 | ]], |
||
| 49 | [ |
||
| 50 | '"Indonesia" "Malaysia" Bali', ['Indonesia', 'Malaysia', 'Bali'], |
||
| 51 | ], |
||
| 52 | [ |
||
| 53 | 'nganu kae', ['nganu', 'kae'], |
||
| 54 | ], |
||
| 55 | [ |
||
| 56 | 'z', ['z'], |
||
| 57 | '', [], |
||
| 58 | ], |
||
| 59 | ]; |
||
| 60 | it.each(dataSet2)('Extract message and command', (input, expectedValue) => { |
||
| 61 | const extractedStrings = extractMessageAndConfig(input); |
||
| 62 | |||
| 63 | expect(extractedStrings).toEqual(expectedValue); |
||
| 64 | }); |
||
| 65 | |||
| 66 | const dataSet3 = [ |
||
| 67 | [ |
||
| 68 | '"anu kae" "super" "sekali kae lo"', []], |
||
| 69 | [ |
||
| 70 | '"Indonesia" "Malaysia" Bali', ['Bali'], |
||
| 71 | ], |
||
| 72 | [ |
||
| 73 | 'nganu kae', ['nganu', 'kae'], |
||
| 74 | ], |
||
| 75 | [ |
||
| 76 | 'z', ['z'], |
||
| 77 | '', [], |
||
| 78 | ], |
||
| 79 | ]; |
||
| 80 | it.each(dataSet3)('Extract message and command', (input, expectedValue) => { |
||
| 81 | const extractedStrings = extractConfig(input, extractMessageByDoubleQuote(input)); |
||
| 82 | |||
| 83 | expect(extractedStrings).toEqual(expectedValue); |
||
| 84 | }); |
||
| 85 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.