-
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.
- Loading branch information
Showing
9 changed files
with
899 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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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 { assert } from 'vitest' | ||
import { readFile } from 'fs/promises' | ||
import { FlacTags } from '../src/index' | ||
|
||
export const coverBuffer = await readFile('./test/cover.jpg') | ||
export const tags: FlacTags = { | ||
tagMap: { | ||
title: 'test-title', | ||
artist: ['artist 1', 'artist 2'], | ||
album: 'test-album', | ||
albumSortOrder: 'TEST001', | ||
}, | ||
picture: { | ||
buffer: coverBuffer, | ||
}, | ||
} | ||
export const assertTags = (actualTags: FlacTags) => { | ||
assert.equal(actualTags.tagMap.title, tags.tagMap.title) | ||
assert.deepEqual(actualTags.tagMap.artist, tags.tagMap.artist) | ||
assert.equal(actualTags.tagMap.album, tags.tagMap.album) | ||
assert.equal(actualTags.tagMap.albumSortOrder, tags.tagMap.albumSortOrder) | ||
assert.isTrue(coverBuffer.equals(actualTags.picture?.buffer)) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
import { describe, test } from 'vitest' | ||
import { readFlacTags, readFlacTagsSync } from '../src/index' | ||
import { assertTags } from './common' | ||
|
||
const readPath = './test/audio-read.flac' | ||
describe('read FLAC tags', () => { | ||
test('read async', async () => { | ||
const actualTags = await readFlacTags(readPath) | ||
assertTags(actualTags) | ||
}) | ||
test('read sync', () => { | ||
const actualTags = readFlacTagsSync(readPath) | ||
assertTags(actualTags) | ||
}) | ||
}) |
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,25 @@ | ||
import { describe, test, beforeEach, afterEach } from 'vitest' | ||
import { copyFile, unlink } from 'fs/promises' | ||
import { writeFlacTags, readFlacTags, writeFlacTagsSync, readFlacTagsSync } from '../src/index' | ||
import { assertTags, tags } from './common' | ||
|
||
const sourcePath = './test/audio-blank.flac' | ||
const writePath = './test/audio-write.flac' | ||
beforeEach(async () => { | ||
await copyFile(sourcePath, writePath) | ||
}) | ||
afterEach(async () => { | ||
await unlink(writePath) | ||
}) | ||
describe('write FLAC tags', () => { | ||
test('write async', async () => { | ||
await writeFlacTags(tags, writePath) | ||
const actualTags = await readFlacTags(writePath) | ||
assertTags(actualTags) | ||
}) | ||
test('write sync', () => { | ||
writeFlacTagsSync(tags, writePath) | ||
const actualTags = readFlacTagsSync(writePath) | ||
assertTags(actualTags) | ||
}) | ||
}) |