-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
see: #74 --------- Signed-off-by: Felipe Young <[email protected]> Co-authored-by: Fernando Cuadro <[email protected]>
- Loading branch information
1 parent
921ae5f
commit 16bf71f
Showing
6 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { equal } from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
import { decodeId3TextFrame } from '../../src/id3/util/decodeId3TextFrame.js'; | ||
import { Id3Frame } from '../../src/id3'; | ||
|
||
describe('decodeId3TextFrame', () => { | ||
it('should decode a TXXX frame', () => { | ||
const frame = { | ||
type: 'TXXX', | ||
data: new Uint8Array([0, 102, 111, 111, 0, 97, 98, 99]), | ||
size: 2, // required by the decodeTextFrame function | ||
}; | ||
|
||
const testables = { | ||
decodeId3TextFrame: decodeId3TextFrame, | ||
}; | ||
|
||
const result: Id3Frame | undefined = testables.decodeId3TextFrame(frame); | ||
equal(result!.key, 'TXXX'); | ||
equal(result!.info, 'foo'); | ||
equal(result!.data, 'abc'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { equal } from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
import { isId3Footer } from '../../src/id3/util/isId3Footer.js'; | ||
|
||
const LEADING_BYTE_SIZE = 8; | ||
const TRAILING_BYTE_SIZE = 8; | ||
|
||
describe('isId3Footer', () => { | ||
const mockID3Footer = Uint8Array.from([ | ||
0x33, 0x44, 0x49, 4, 0, 0, 0, 0, 0, 63, 80, 82, 73, 86, 0, 0, 0, 53, 0, 0, | ||
99, 111, 109, 46, 97, 112, 112, 108, 101, 46, 115, 116, 114, 101, 97, 109, | ||
105, 110, 103, 46, 116, 114, 97, 110, 115, 112, 111, 114, 116, 83, 116, 114, | ||
101, 97, 109, 84, 105, 109, 101, 115, 116, 97, 109, 112, 0, 0, 0, 0, 0, 0, | ||
13, 198, 135, | ||
]); | ||
const mockID3FooterMissingLeadingByte = mockID3Footer.slice( | ||
LEADING_BYTE_SIZE, | ||
mockID3Footer.length | ||
); | ||
const mockID3FooterMissingTrailingByte = mockID3Footer.slice( | ||
0, | ||
mockID3Footer.length - TRAILING_BYTE_SIZE | ||
); | ||
|
||
it('Properly parses ID3 Footers', () => { | ||
equal(isId3Footer(mockID3Footer, 0), true); | ||
equal(isId3Footer(mockID3FooterMissingLeadingByte, 0), false); | ||
equal(isId3Footer(mockID3FooterMissingTrailingByte, 0), true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { equal } from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
import { isId3Header } from '../../src/id3/util/isId3Header.js'; | ||
|
||
const LEADING_BYTE_SIZE = 8; | ||
const TRAILING_BYTE_SIZE = 8; | ||
|
||
describe('isId3Header', () => { | ||
const mockID3Header = Uint8Array.from([ | ||
73, 68, 51, 4, 0, 0, 0, 0, 0, 63, 80, 82, 73, 86, 0, 0, 0, 53, 0, 0, 99, | ||
111, 109, 46, 97, 112, 112, 108, 101, 46, 115, 116, 114, 101, 97, 109, 105, | ||
110, 103, 46, 116, 114, 97, 110, 115, 112, 111, 114, 116, 83, 116, 114, 101, | ||
97, 109, 84, 105, 109, 101, 115, 116, 97, 109, 112, 0, 0, 0, 0, 0, 0, 13, | ||
198, 135, | ||
]); | ||
const mockID3HeaderMissingLeadingByte = mockID3Header.slice( | ||
LEADING_BYTE_SIZE, | ||
mockID3Header.length | ||
); | ||
const mockID3HeaderMissingTrailingByte = mockID3Header.slice( | ||
0, | ||
mockID3Header.length - TRAILING_BYTE_SIZE | ||
); | ||
|
||
it('Properly parses ID3 Headers', () => { | ||
equal(isId3Header(mockID3Header, 0), true); | ||
equal(isId3Header(mockID3HeaderMissingLeadingByte, 0), false); | ||
equal(isId3Header(mockID3HeaderMissingTrailingByte, 0), true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { equal } from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
import { readId3Size } from '../../src/id3/util/readId3Size.js'; | ||
|
||
describe('readId3Size', () => { | ||
const mockID3SizeData = Uint8Array.from([73, 68, 51, 4, 0, 0, 0, 7, 1, 0]); | ||
it('returns Id3 size', () => { | ||
equal(readId3Size(mockID3SizeData, 6), 114816); | ||
}); | ||
}); |