All files / rusted-chromium/commons MappedVersion.ts

85% Statements 17/20
64.7% Branches 11/17
100% Functions 5/5
85% Lines 17/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49  4x 4x   4x           63x       61x       47x       5x               30x 2x 2x 28x 4x 4x   24x     24x 24x 24x            
import type { IVersionWithDisabled } from '../interfaces/interfaces'
import { isIVersionWithDisabled } from '../utils/typeguards'
import { ComparableVersion } from './ComparableVersion'
 
export class MappedVersion {
 
    private _comparableVersion: ComparableVersion
    private _disabled: boolean
 
    public get comparable(): ComparableVersion {
        return this._comparableVersion
    }
 
    public get value(): string {
        return this._comparableVersion.toString()
    }
 
    public get disabled(): boolean {
        return this._disabled
    }
 
    public disable(): void {
        this._disabled = true
    }
 
    public constructor(input: string, disabled: boolean)
    public constructor(major: number, minor: number, branch: number, patch: number, disabled: boolean)
    public constructor(versionObject: IVersionWithDisabled)
    public constructor(comparableVersion: ComparableVersion, disabled: boolean)
    public constructor(majorObjectInput: number | string | IVersionWithDisabled | ComparableVersion, minorDisabled?: number | boolean, branch?: number, patch?: number, disabled?: boolean) {
        if (majorObjectInput instanceof ComparableVersion && typeof minorDisabled === 'boolean') {
            this._comparableVersion = majorObjectInput
            this._disabled = minorDisabled
        } else if (isIVersionWithDisabled(majorObjectInput)) {
            this._comparableVersion = new ComparableVersion(majorObjectInput)
            this._disabled = majorObjectInput.disabled
        }
        else Iif (typeof majorObjectInput === 'number' && typeof minorDisabled === 'number' && typeof branch === 'number' && typeof patch === 'number' && typeof disabled === 'boolean') {
            this._comparableVersion = new ComparableVersion(majorObjectInput, minorDisabled, branch, patch)
            this._disabled = disabled
        } else if (typeof majorObjectInput === 'string' && typeof minorDisabled === 'boolean') {
            this._comparableVersion = new ComparableVersion(majorObjectInput)
            this._disabled = minorDisabled
        } else E{
            throw new Error('This should not happen, MappedVersion called with wrong types!')
        }
    }
}