{"id":24988706,"url":"https://github.com/maptalks/expect-maptalks","last_synced_at":"2025-08-08T14:10:53.815Z","repository":{"id":71330149,"uuid":"61091088","full_name":"maptalks/expect-maptalks","owner":"maptalks","description":"A plugin of expect.js for maptalks with assertions for Coordinate/GeoJSON/Layer","archived":false,"fork":false,"pushed_at":"2017-05-05T16:19:02.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T00:09:56.903Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maptalks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-14T04:13:20.000Z","updated_at":"2023-01-29T06:20:01.000Z","dependencies_parsed_at":"2023-03-13T20:20:38.490Z","dependency_job_id":null,"html_url":"https://github.com/maptalks/expect-maptalks","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maptalks%2Fexpect-maptalks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maptalks%2Fexpect-maptalks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maptalks%2Fexpect-maptalks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maptalks%2Fexpect-maptalks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maptalks","download_url":"https://codeload.github.com/maptalks/expect-maptalks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497809,"owners_count":21113984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T12:05:08.063Z","updated_at":"2025-04-12T00:10:23.592Z","avatar_url":"https://github.com/maptalks.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# expect-maptalks\n\n[![Circle CI](https://circleci.com/gh/maptalks/expect-maptalks.svg?style=shield)](https://circleci.com/gh/maptalks/expect-maptalks)\n\nA plugin of expect.js(https://github.com/Automattic/expect.js) for maptalks with assertions for Coordinate/GeoJSON/Layer\n\n## Usage\n\n```bash\nnpm install expect-maptalks --save-dev\n```\n\n### with Karma\nInstall [karma-expect-maptalks](https://github.com/MapTalks/karma-expect-maptalks)\n```bash\nnpm install karma-expect-maptalks --save-dev\n```\nIn karma.conf.js, Attention: **always declare expect-maptalks behind expect**\n```javascript\n    frameworks: [\n      'mocha',\n      'expect',\n      'expect-maptalks'\n    ],\n    \n    plugins: [\n      'karma-expect',\n      'karma-expect-maptalks'\n    ],\n```\n\n\n## Methods\n\n**approx**: asserts that the value is approximately equal or not\n\n```js\nexpect(1.000001).to.be.approx(1);\nexpect(1.001).to.be.approx(1, 1E-2);\n```\n\n**closeTo**: asserts that whether the coordinate is closeTo another (approx with a delta of 1E-6)\n\n```js\nexpect([1, 1]).to.be.closeTo([1 + 1E-7, 1 - 1E-7]);\nexpect({x : 1, y : 1}).to.be.closeTo([1 + 1E-7, 1 - 1E-7]);\n```\n\n**eqlGeoJSON**: asserts that whether a GeoJSON object is equal with another (true if the coordinates are closeTo another's)\n\n```js\n//true\nexpect({ \"type\": \"Point\", \"coordinates\": [0.0, 0.0] })\n    .to.be.eqlGeoJSON({ \"type\": \"Point\", \"coordinates\": [0.000001, 0.000001] });\n```\n\n**painted**: asserts the given layer or map is painted in the center with a offset.\n\n```js\nvar v = new maptalks.VectorLayer('v').addGeometries(geos).addTo(map);\n//asserts layer is painted in the center\nexpect(v).to.be.painted();\n//whether the layer is painted with an offset {x:5, y:3} from the center.\n//a negative x to the left and a positive to the right.\n//a negative y to the top and a positive to the bottom.\nexpect(v).to.be.painted(5, 3);\n//assert the point's color is [255, 255, 255]\nexpect(v).to.be.painted(5, 3, [255, 255, 255]);\n//also support map\nexpect(map).to.be.painted(5, 3, [255, 255, 255]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaptalks%2Fexpect-maptalks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaptalks%2Fexpect-maptalks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaptalks%2Fexpect-maptalks/lists"}