New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jasmine-parameterized

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-parameterized

Parameterized unit tests for Jasmine

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
3.1K
53.44%
Maintainers
1
Weekly downloads
 
Created
Source

Jasmine-Parameterized

Build Status

Parameterized unit tests for Jasmine.

Installation

npm install jasmine-parameterized

Usage

This library provides a convenient cases function to easily parameterized the execution of it spec functions.

Examples

Single parameter

import { cases } from 'jasmine-parameterized';

describe('Customer', () => {

    cases([
        4,
        14
    ])
    .it('should be a child when aged 4 to 14 years', (age) => {
        const customer = new Customer(age);
        expect(customer.isChild()).toBe(true);
    });
...

single param

Multiple parameters

describe('Roman Numeral Converter', () => {

    cases([
        [1, 'I'],
        [2, 'II'],
        [3, 'III'],
        [4, 'IV'],
        [5, 'V'],
        [6, 'VI']
    ])
    .it('converts Arabic number to its equivalent Roman numeral', ([arabic, roman]) => {
        expect(romanFor(arabic)).toBe(roman);
    });

});

multiple params

Multiple named parameters

For complex cases or when we want to be more explicit.

describe('Fibonacci Sequence', () => {

    describe('First two numbers', () => {
        cases([
            {index: 0, expected: 0},
            {index: 1, expected: 1}
        ])
        .it('should be same as index', ({index, expected}) => {
            expect(fibonacciNumber(index)).toEqual(expected);
        });
    });

    describe('Third number on', () => {
        cases([
            {index: 2, expected: 1},
            {index: 3, expected: 2},
            {index: 5, expected: 5}
        ])
        .it('should be the sum of previous two', ({index, expected}) => {
            expect(fibonacciNumber(index)).toEqual(expected);
        });
    });

});

multiple named params

Keywords

parameterised

FAQs

Package last updated on 27 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts