Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

web-devil/ts-using

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published