# All files / infrastructure/files file.engine.spec.ts

100% Statements 25/25
100% Branches 2/2
100% Functions 6/6
100% Lines 20/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
    341x

    1x

    1x

    1x
    1x
    1x

    1x
    1x
    1x

    1x
    1x
    1x

    1x
    2x
    1x
    1x

    1x
    1x
    1x
    1x

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

    import FileEngine from './file.engine';

    const rimraf = require('rimraf');

    describe('Infrastructure - FileEngine', () => {
        after(() => {
            rimraf.sync('tmp');
        });

        it('should read async file', async () => {
            const fileData = await FileEngine.get('package.json');
            expect(fileData).contain('@compodoc/compodoc');
        });

        it('should read sync file', () => {
            const fileData = FileEngine.getSync('package.json');
            expect(fileData).contain('@compodoc/compodoc');
        });

        it('should write async file', async () => {
            await FileEngine.write('tmp/test-async.js', 'TEST');
            const fileData = await FileEngine.get('tmp/test-async.js');
            expect(fileData).contain('TEST');
        });

        it('should write sync file', async () => {
            FileEngine.writeSync('tmp/test-sync.js', 'TEST');
            const fileData = FileEngine.getSync('tmp/test-sync.js');
            expect(fileData).contain('TEST');
        });
    });