# All files / infrastructure/angular angular-version.util.spec.ts

100% Statements 22/22
100% Branches 0/0
100% Functions 5/5
100% Lines 22/22

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
    50
    51
    521x

    1x

    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x

    1x
    1x

    1x
    1x

    1x
    1x

    1x
    1x

    1x

     const expect = require('chai').expect;

    import AngularVersionUtil from './angular-version.util';

    describe('Infrastructure - Manage Angular APIs', () => {
        const finalCleanedVersion = '8.0.1';

        it('should clean version', () => {
            let version = '~8.0.1';
            let cleanedVersion = AngularVersionUtil.cleanVersion(version);
            expect(cleanedVersion).equal(finalCleanedVersion);
            version = '^8.0.1';
            cleanedVersion = AngularVersionUtil.cleanVersion(version);
            expect(cleanedVersion).equal(finalCleanedVersion);
        });

        it('should retrieve Angular version of project', () => {
            const packageData = {
                dependencies: {
                    '@angular/core': '~8.0.1'
                }
            };
            const version = AngularVersionUtil.getAngularVersionOfProject(packageData);
            expect(version).equal(finalCleanedVersion);
        });

        it('should not retrieve Angular version of project', () => {
            const packageData = {
                dependencies: {
                    'vue.js': '~8.0.1'
                }
            };
            const version = AngularVersionUtil.getAngularVersionOfProject(packageData);
            expect(version).equal('');
        });

        it('should getApiLink for API', () => {
            const apiLink = AngularVersionUtil.getApiLink(
                {
                    title: 'NgModule',
                    path: 'api/core/NgModule',
                    docType: 'decorator',
                    stability: 'stable',
                    secure: '',
                    barrel: ''
                },
                '8.0.1'
            );
            expect(apiLink).equal('https://angular.io/api/core/NgModule');
        });
    });