All files parseable_file_test.ts

100% Statements 25/25
100% Branches 0/0
100% Functions 7/7
100% Lines 19/19

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 291x 1x 1x 1x 1x 3x   1x 1x 3x       1x 1x 1x   1x 1x 1x   1x 1x 1x 1x        
import * as path from 'path';
import * as mock from 'mock-fs';
import {strictEqual, throws} from 'assert';
import {ParseableFile} from './parsable_file';
const cwd = process.cwd();
const here = (filename: string) => path.join(cwd, filename);
 
describe('ParseableFile', () => {
  beforeEach(() =>
    mock({
      [here('hello.txt')]: 'hello world',
    })
  );
  it('should get content', async () => {
    const p = new ParseableFile({basename: './hello.txt'});
    strictEqual(await p.parsedContent, 'hello world');
  });
  it('should stringify', async () => {
    const p = new ParseableFile({basename: './hello.txt'});
    strictEqual(p.stringify('hello world'), 'hello world');
  });
  it('should throw when unimplemented stringify', async () => {
    const p = new ParseableFile<boolean>({basename: './hello.txt'});
    throws(() => {
      p.stringify(true);
    });
  });
});