|
| 1 | +import { assertEquals } from 'std/assert/assert_equals.ts'; |
| 2 | +import { assertThrows } from 'std/assert/assert_throws.ts'; |
| 3 | +import { describe, it } from '@std/testing/bdd'; |
| 4 | +import { extractMBID } from './extract_mbid.ts'; |
| 5 | + |
| 6 | +describe('extractMBID', () => { |
| 7 | + it('accepts a v4 UUID', () => { |
| 8 | + const v4uuid = 'e5a77768-ff64-46f2-a13e-9d368b413cff'; |
| 9 | + assertEquals(extractMBID(v4uuid), v4uuid); |
| 10 | + }); |
| 11 | + |
| 12 | + it('accepts a v3 UUID', () => { |
| 13 | + const v3uuid = '9706e7fa-4ed1-3b40-b638-45a21ff634f5'; |
| 14 | + assertEquals(extractMBID(v3uuid), v3uuid); |
| 15 | + }); |
| 16 | + |
| 17 | + it('accepts a MusicBrainz entity link', () => { |
| 18 | + assertEquals( |
| 19 | + extractMBID('https://musicbrainz.org/recording/e5a77768-ff64-46f2-a13e-9d368b413cff'), |
| 20 | + 'e5a77768-ff64-46f2-a13e-9d368b413cff', |
| 21 | + ); |
| 22 | + }); |
| 23 | + |
| 24 | + it('accepts only MusicBrainz entity links with the expected type', () => { |
| 25 | + assertEquals( |
| 26 | + extractMBID('https://beta.musicbrainz.org/release/da14004d-f6af-4dd7-aab7-033bef53e805', ['release']), |
| 27 | + 'da14004d-f6af-4dd7-aab7-033bef53e805', |
| 28 | + ); |
| 29 | + assertThrows( |
| 30 | + () => extractMBID('https://musicbrainz.org/recording/e5a77768-ff64-46f2-a13e-9d368b413cff', ['release']), |
| 31 | + ); |
| 32 | + }); |
| 33 | + |
| 34 | + it('rejects any other text', () => { |
| 35 | + assertThrows(() => extractMBID('test')); |
| 36 | + }); |
| 37 | +}); |
0 commit comments