1.0.1 • Published 5 years ago

@web-devil/ts-using v1.0.1

Weekly downloads
40
License
MIT
Repository
github
Last release
5 years ago

ts-using

A TypeScript/JavaScript module for adding using function. This is known as a data provider, eg. in jasmine-data-provider. Unfortunately, this is using the "require"-syntax. With this module you can use the known simple "import".

Usage

Add the import statement for the import function.

import {using} from '@web-devil/ts-using'

Use it as a data provider for your test.

using([//data], (args) => {it(...);}

Full example:

import {using} from '@web-devil/ts-using';
import { BarPipe } from './bar.pipe';

describe('BarPipe', () => {
  using([
    ['single bar', 'foo bar', 'bar'],
    ['multiple bar', 'bar bar', 'bar bar'],
    // more cases easily added ...
  ], (testCase, inputValue, expectedValue) => {
    it('only returns "bar" in a string: ' + testCase, () => {
      const pipe = new BarPipe();

      expect(pipe.transform(inputValue)).toBe(expectedValue);
    });
  });
});

Installation

Install package from npm-registry

npm install @web-devil/ts-using -D

That's it!