also looking at this
Fix the failing tests
#47
1 file
+22
-16
| @@ -237,7 +237,7 @@ describe('punycode', () => { | ||
| 237 | 237 | }) |
| 238 | 238 | |
| 239 | 239 | it('should throw on invalid input', () => { |
| 240 | expect(() => punycode.decode('xyz-')).toThrow('Invalid input') | |
| 240 | expect(() => punycode.decode('abc-!')).toThrow('Invalid input') | |
| 241 | 241 | }) |
| 242 | 242 | }) |
| 243 | 243 | |
| @@ -286,18 +286,6 @@ describe('punycode.ucs2.decode', () => { | ||
| 286 | 286 | expect(punycode.ucs2.decode(object.encoded)).toEqual(object.decoded) |
| 287 | 287 | }) |
| 288 | 288 | } |
| 289 | ||
| 290 | it('throws RangeError: Illegal input >= 0x80 (not a basic code point)', () => { | |
| 291 | expect(() => { | |
| 292 | punycode.decode('\x81-') | |
| 293 | }).toThrow('Illegal input >= 0x80 (not a basic code point)') | |
| 294 | }) | |
| 295 | ||
| 296 | it('throws RangeError: Overflow: input needs wider integers to process', () => { | |
| 297 | expect(() => { | |
| 298 | punycode.decode('\x81') | |
| 299 | }).toThrow('Overflow: input needs wider integers to process') | |
| 300 | }) | |
| 301 | 289 | }) |
| 302 | 290 | |
| 303 | 291 | describe('punycode.ucs2.encode', () => { |
| @@ -331,6 +319,24 @@ describe('punycode.decode', () => { | ||
| 331 | 319 | punycode.decode('ls8h=') |
| 332 | 320 | }).toThrow('Invalid input') |
| 333 | 321 | }) |
| 322 | ||
| 323 | it('throws RangeError: Illegal input >= 0x80 (not a basic code point)', () => { | |
| 324 | expect(() => { | |
| 325 | punycode.decode('\x81-') | |
| 326 | }).toThrow('Illegal input >= 0x80 (not a basic code point)') | |
| 327 | }) | |
| 328 | ||
| 329 | it('throws RangeError: Invalid input for non-basic code point without delimiter', () => { | |
| 330 | expect(() => { | |
| 331 | punycode.decode('\x81') | |
| 332 | }).toThrow('Invalid input') | |
| 333 | }) | |
| 334 | ||
| 335 | it('throws RangeError: Overflow for input needing wider integers', () => { | |
| 336 | expect(() => { | |
| 337 | punycode.decode('bb000000') | |
| 338 | }).toThrow('Overflow: input needs wider integers to process') | |
| 339 | }) | |
| 334 | 340 | }) |
| 335 | 341 | |
| 336 | 342 | describe('punycode.encode', () => { |
| @@ -349,7 +355,7 @@ describe('punycode.toUnicode', () => { | ||
| 349 | 355 | } |
| 350 | 356 | |
| 351 | 357 | for (const object of testData.strings) { |
| 352 | it('does not convert names (or other strings) that don\'t start with `xn--`', () => { | |
| 358 | it(`does not convert non-xn-- strings: ${object.description || object.encoded}`, () => { | |
| 353 | 359 | expect(punycode.toUnicode(object.encoded)).toBe(object.encoded) |
| 354 | 360 | expect(punycode.toUnicode(object.decoded)).toBe(object.decoded) |
| 355 | 361 | }) |
| @@ -364,13 +370,13 @@ describe('punycode.toASCII', () => { | ||
| 364 | 370 | } |
| 365 | 371 | |
| 366 | 372 | for (const object of testData.strings) { |
| 367 | it('does not convert domain names (or other strings) that are already in ASCII', () => { | |
| 373 | it(`does not convert ASCII-only strings: ${object.description || object.encoded}`, () => { | |
| 368 | 374 | expect(punycode.toASCII(object.encoded)).toBe(object.encoded) |
| 369 | 375 | }) |
| 370 | 376 | } |
| 371 | 377 | |
| 372 | 378 | for (const object of testData.separators) { |
| 373 | it('supports IDNA2003 separators for backwards compatibility', () => { | |
| 379 | it(`supports IDNA2003 separators: ${object.description}`, () => { | |
| 374 | 380 | expect(punycode.toASCII(object.decoded)).toBe(object.encoded) |
| 375 | 381 | }) |
| 376 | 382 | } |