• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

benrr101 / node-taglib-sharp / 46462134

pending completion
46462134

push

appveyor

Benjamin Russell
Merge branch 'release/v5.1.0'

3096 of 3788 branches covered (81.73%)

Branch coverage included in aggregate %.

2171 of 2171 new or added lines in 47 files covered. (100.0%)

25320 of 26463 relevant lines covered (95.68%)

437.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.23
/test-unit/utilities/testFile.ts
1
import * as TypeMoq from "typemoq";
1✔
2

3
import TestConstants from "../testConstants";
1✔
4
import TestStream from "./testStream";
1✔
5
import {ByteVector} from "../../src/byteVector";
1✔
6
import {File} from "../../src/file";
7
import {IStream, SeekOrigin} from "../../src/stream";
1✔
8
import {IFileAbstraction} from "../../src/fileAbstraction";
9

10
export type TestFileAbstraction = IFileAbstraction & {allBytes: ByteVector};
11
export default {
1✔
12
    mockFile: (): File => { return TypeMoq.Mock.ofType<File>().object; },
31✔
13
    getFile: (data: ByteVector|number[]): File => {
14
        const mockFile = TypeMoq.Mock.ofType<File>();
625✔
15
        let position = 0;
625✔
16

17
        const dataBv = data instanceof ByteVector
625✔
18
            ? data
625✔
19
            : ByteVector.fromByteArray(data);
20

21
        mockFile.setup((f) => f.length).returns(() => dataBv.length);
625✔
22
        mockFile.setup((f) => f.seek(TypeMoq.It.isAnyNumber(), <SeekOrigin>TypeMoq.It.isAny()))
625✔
23
            .returns((p: number, o: SeekOrigin) => {
24
                switch (o || SeekOrigin.Begin) {
847✔
25
                    case SeekOrigin.Begin:
847!
26
                        position = Math.min(dataBv.length, p);
847✔
27
                        break;
847✔
28
                    case SeekOrigin.Current:
29
                        position = Math.min(dataBv.length, position + p);
×
30
                        break;
×
31
                    case SeekOrigin.End:
32
                        position = Math.min(dataBv.length, dataBv.length + p);
×
33
                        break;
×
34
                }
35
            });
36
        mockFile.setup((f) => f.readBlock(TypeMoq.It.isAnyNumber()))
625✔
37
            .returns((s: number) => {
38
                if (position + s > dataBv.length) {
2,023✔
39
                    s = dataBv.length - position;
50✔
40
                }
41
                if (s <= 0) {
2,023✔
42
                    return ByteVector.empty();
10✔
43
                }
44

45
                const output = dataBv.subarray(position, s);
2,013✔
46
                position += s;
2,013✔
47
                return output;
2,013✔
48
            });
49
        mockFile.setup((f) => f.position)
625✔
50
            .returns(() => {
51
                return position;
132✔
52
            });
53
        mockFile.setup((f) => f.mode);
625✔
54

55
        return mockFile.object;
625✔
56
    },
57
    getFileAbstraction: (data: ByteVector): TestFileAbstraction => {
58
        return {
110✔
59
            name: TestConstants.name,
60
            get allBytes(): ByteVector { return data; },
50✔
61
            get readStream(): IStream { return new TestStream(data, false); },
120✔
62
            get writeStream(): IStream { return new TestStream(data, true); },
43✔
63
            closeStream: (stream: IStream): void => { stream.close(); }
142✔
64
        };
65
    }
66
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc