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

expect-maptalks

v0.4.1

Published

A plugin of expect.js(https://github.com/Automattic/expect.js) for maptalks with assertions for Coordinate/GeoJSON/Layer

Downloads

154

Readme

expect-maptalks

Circle CI

A plugin of expect.js(https://github.com/Automattic/expect.js) for maptalks with assertions for Coordinate/GeoJSON/Layer

Usage

npm install expect-maptalks --save-dev

with Karma

Install karma-expect-maptalks

npm install karma-expect-maptalks --save-dev

In karma.conf.js, Attention: always declare expect-maptalks behind expect

    frameworks: [
      'mocha',
      'expect',
      'expect-maptalks'
    ],
    
    plugins: [
      'karma-expect',
      'karma-expect-maptalks'
    ],

Methods

approx: asserts that the value is approximately equal or not

expect(1.000001).to.be.approx(1);
expect(1.001).to.be.approx(1, 1E-2);

closeTo: asserts that whether the coordinate is closeTo another (approx with a delta of 1E-6)

expect([1, 1]).to.be.closeTo([1 + 1E-7, 1 - 1E-7]);
expect({x : 1, y : 1}).to.be.closeTo([1 + 1E-7, 1 - 1E-7]);

eqlGeoJSON: asserts that whether a GeoJSON object is equal with another (true if the coordinates are closeTo another's)

//true
expect({ "type": "Point", "coordinates": [0.0, 0.0] })
    .to.be.eqlGeoJSON({ "type": "Point", "coordinates": [0.000001, 0.000001] });

painted: asserts the given layer or map is painted in the center with a offset.

var v = new maptalks.VectorLayer('v').addGeometries(geos).addTo(map);
//asserts layer is painted in the center
expect(v).to.be.painted();
//whether the layer is painted with an offset {x:5, y:3} from the center.
//a negative x to the left and a positive to the right.
//a negative y to the top and a positive to the bottom.
expect(v).to.be.painted(5, 3);
//assert the point's color is [255, 255, 255]
expect(v).to.be.painted(5, 3, [255, 255, 255]);
//also support map
expect(map).to.be.painted(5, 3, [255, 255, 255]);