npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-jasmine-immutable-matchers

v1.0.2

Published

Jasmine Immutable Matchers for Typescript

Downloads

61

Readme

ts-jasmine-immutable-matchers

Jasmine custom matchers for Immutablejs.

Installation

$ npm install --save-dev ts-jasmine-immutable-matchers

(I know, the module name is pretty long ¯_(ツ)_/¯)

Usage

Load the matchers in a beforeEach block.

import { matchers } from "ts-jasmine-immutable-matchers";

declare("Your Awesome Tests", () => {
  beforeEach(() => jasmine.addMatchers(matchers));
});

API

toBeImmutable

Asserts that the data structure is immutable.

import { List } from "immutable";

declare("Immutable", () => {
  it("is not immutable", () => {
    const arr = [1, 2];
    expect(arr).not.toBeImmutable();
  });

  it("is immutable", () => {
    const list = List.of(1, 2);
    expect(list).toBeImmutable();
  })
});

toBeIterableImmutable

Asserts that the data structure is an iterable immutable.

import { List } from "immutable";

declare("Iterable immutable", () => {
  it("is not an iterable immutable", () => {
    const arr = [1, 2];
    expect(arr).not.toBeIterableImmutable();
  });
  
  it("is an iterable immutable", () => {
    const list = List.of(1, 2);
    expect(list).toBeIterableImmutable();
  })
});

toBeKeyedImmutable

Asserts that the data structure is keyed immutable structure.

import { Map, List } from "immutable";

declare("Keyed immutable", () => {
  it("it is not a keyed immutable", () => {
    const list = List.of(1, 2);
    expect(list).not.toBeKeyedImmutable();
  });
  
  it("is a keyed immutable", () => {
    const map = Map({ a: 1 });
    expect(map).toBeKeyedImmutable();
  });
});

toBeIndexedImmutable

Asserts that the data structure is an indexed immutable structure.

import { Map, List } from "immutable";

declare("Indexed Immutable", () => {
  it("is not an indexed immutable", () => {
    const map = Map({ a: 1 });
    expect(map).not.toBeIndexedImmutable();
  }):
  
  it("is an indexed immutable", () => {
    const list = List.of(1, 2);
    expect(list).toBeIndexedImmutable();
  });
});

toBeAssociativeImmutable

Asserts that the data structure is an associative immutable structure.

import { fromJS, Map } from "immutable";

declare("Associtive Immutable", () => {
  it("is not an associative immutable", () => {
    const f = fromJS("not associative");
    expect(f).not.toBeAssociativeImmutable();
  });
  
  it("is an associative immutable", () => {
    const map = Map({ a: 1 });
    expect(m).toBeAssociativeImmutable();
  });
});

toBeOrderedImmutable

Asserts that the data structure is an ordered immutable structure.

import { Map, List, OrderedMap, OrderedSet } from "immutable";

declare("Ordered Immutable", () => {
  it("is not ann ordered immutable", () => {
    const map = Map({ a: 1 });
    expect(map).not.toBeOrderedImmutable();
  });
  
  it("is an ordered immutable", () => {
    const l = List.of(1, 2);
    const o = OrderedMap({ a: 1 }, {b: 2});
    const s = OrderedSet([1, 2]);
    expect(l).toBeOrderedImmutable();
    expect(o).toBeOrderedImmutable();
    expect(s).toBeOrderedImmutable();
  });
});

toBeImmutableList

Asserts that the data structure is an immutable list.

import { List, Map } from "immutable";

declare("Immutable List", () => {
  it("it is not an immutable list", () => {
    const map = Map({ a: 1 });
    expect(m).not.toBeImmutableList();
  });
  
  it("is an immutable list", () => {
    const l1 = List.of(1, 2);
    const l2 = List([1, 2]);
    expect(l1).toBeImmutableList();
    expect(l2).toBeImmutableList();
  });
});

toBeImmutableMap

Asserts that the data structure is an immutable map.

import { List, Map } from "immutable";

declare("Immutable Map", () => {
  it("is not an immutable map", () => {
    const l = List.of(1, 2);
    expect(l).not.toBeImmutableMap();
  });
  
  it("is an immutable map", () => {
    const m = Map({ a: 1 });
    expect(m).toBeImmutableMap();
  });
});

toBeImmutableOrderedMap

Asserts that the data structure is an immutable ordered map.

import { Map, OrderedMap } from "immutable";

declare("Immutable Ordered Map", () => {
  it("is not an ordered immutable map", () => {
    const m = Map({ a: 1 });
    expect(m).not.toBeImmutableOrderedMap();
  });
  
  it("is an immutable map", () => {
    const o = OrdereMap({ a: 1 }, { b: 2 });
    expect(o).toBeImmutableOrderedMap();
  });
});

toBeImmutableOrderedSet

Asserts that the data structure is an immutable ordered set.

import { OrderedSet, Map } from "immutable";

declare("Immutable Oredered Set", () => {
  it("is not an ordered immutable set", () => {
    const m = Map({a: 1});
    expect(m).not.toBeImmutableOrderedSet();
  });
  
  it("is an ordered immutable set", () => {
    const s = OrderedSet([1, 2]);
    expect(s).toBeImmutableOrderedSet();
  });
});

toBeImmutableSet

Asserts that the data structure is an immutable set.

import { Set, Map } from "immutable";

declare("Immutable Set", () => {
  it("is not an immutable set", () => {
    const m = Map({ a: 1 });
    expect(m).not.toBeImmutableSet();
  });
  
  it("is an immutable set", () => {
    const s = Set([1, 2]);
    expect(s).toBeImmutableSet();
  });
});

toBeImmutableStack

Asserts that the data structure is an immutable stack.

improt { Stack } from "immutable";

declare("Immutable Stack", () => {
  it("is not an immutable stack", () => {
    const a = [1, 2];
    expect(a).not.toBeImmutableStack();
  });
  
  it("is an immutable stack", () => {
    const s = Stack([1, 2]);
    expect(s).toBeImmutableStack();
  });
});

toBeImmutableSeq

Asserts that the structure is an immutable sequence.

import { Seq } from "immutable";

declare("Immutable Sequence", () => {
  it("is not an immutable sequence", () => {
    const a = [1, 2];
    expect(a).not.toBeImmutableSeq();
  });
  
  it("is an immutable sequence", () => {
    const s = Seq([1, 2]);
    expect(s).toBeImmutableSeq();
  });
});

toEqualImmutable

Asserts that the input immutable argument is equal to expected immutable input.

import { Map, List } from "immutable";

declare("Equal another Immutable", () => {
  it("does not equal another immutable list", () => {
    const l1 = List.of(1, 2);
    const l2 = List.of(1, 2, 3);
    expect(l1).not.toBe(l2);
    expect(l1).not.toEqualImmutable(l2);
  });
  
  it("is equal to another immutable list", () => {
    const l1 = List.of(1, 2);
    const l2 = List.of(1, 2);
    expect(l1).not.toBe(l2);
    expect(l1).toEqualImmutable(l2);
  });
  
  it("does not equal another immutable map", () => {
    const m1 = Map({ a: 1 });
    const m2 = Map({ b: 2 })
    expect(m1).not.toBe(m2);
    expect(m1).not.toEqualImmutable();
  });
  
  it("is equal to another immutable map", () => {
    const m1 = Map({ a: 1 });
    const m2 = Map({ a: 1 });
    expect(m1).not.toBe(m2);
    expect(m1).toEqualImmutable();
  });
});