jasmine-immutable-matchers
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0 • Public • Published

    jasmine-immutable-matchers Version

    List of matchers

    • toBeImmutable
    • toBeIterableImmutable
    • toBeKeyedImmutable
    • toBeIndexedImmutable
    • toBeAssociativeImmutable
    • toBeOrderedImmutable
    • toBeImmutableList
    • toBeImmutableMap
    • toBeImmutableOrderedMap
    • toBeImmutableSet
    • toBeImmutableOrderedSet
    • toBeImmutableStack
    • toBeImmutableSeq
    • toEqualImmutable

    Installation

    Just run:

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

    Usage

    Load these matchers in a beforeEach block, and then use them like any other matcher:

    expect(Immutable.Map()).toBeImmutable()

    TypeScript

    This package includes the necessary declarations for TypeScript. Just make sure they get loaded in your project, for example by adding the package name to the types field in your tsconfig.json:

    {
      "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "types": [
          "jasmine",
          "jasmine-immutable-matchers"
        ]
      }
    }

    Then just load the matchers at runtime in your tests:

    import * as matchers from 'jasmine-immutable-matchers';
    
    describe('My suite', function () {
      beforeEach(function () {
        jasmine.addMatchers(matchers);
      });
    
      it('passes if the object is immutable', function () {
        expect(Immutable.Map()).toBeImmutable();
      });
    
      it('passes if the immutable objects are equal', function () {
        expect(Immutable.Map({a: 1})).toEqualImmutable(Immutable.Map({a: 1}));
      });
    });

    ES2015

    If you are using the new module syntax, import all exported matchers:

    import * as matchers from 'jasmine-immutable-matchers';
    
    describe('My suite', function () {
      beforeEach(function () {
        jasmine.addMatchers(matchers);
      });
    
      it('passes if the object is immutable', function () {
        expect(Immutable.Map()).toBeImmutable();
      });
    
      it('passes if the immutable objects are equal', function () {
        expect(Immutable.Map({a: 1})).toEqualImmutable(Immutable.Map({a: 1}));
      });
    });

    Note that jasmine-immutable-matchers does not have a default export!

    AMD/CommonJS

    If you are using AMD or CommonJS, require normally:

    var matchers = require('jasmine-immutable-matchers');
    
    describe('My suite', function () {
      beforeEach(function () {
        jasmine.addMatchers(matchers);
      });
    
      it('passes if the object is immutable', function () {
        expect(Immutable.Map()).toBeImmutable();
      });
    
      it('passes if the immutable objects are equal', function () {
        expect(Immutable.Map({a: 1})).toEqualImmutable(Immutable.Map({a: 1}));
      });
    });

    Global

    Otherwise, use window['jasmine-immutable-matchers']:

    var matchers = window['jasmine-immutable-matchers'];
    
    describe('My suite', function () {
      beforeEach(function () {
        jasmine.addMatchers(matchers);
      });
    
      it('passes if the object is immutable', function () {
        expect(Immutable.Map()).toBeImmutable();
      });
    
      it('passes if the immutable objects are equal', function () {
        expect(Immutable.Map({a: 1})).toEqualImmutable(Immutable.Map({a: 1}));
      });
    });

    Install

    npm i jasmine-immutable-matchers

    DownloadsWeekly Downloads

    760

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    19.2 kB

    Total Files

    6

    Last publish

    Collaborators

    • unindented