Skip to content

Commit 445801c

Browse files
committed
QUnit: Implement matchJson() assertion
1 parent 27e6f6f commit 445801c

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

package-lock.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"eslint-plugin-prettier": "^3.1.2",
8484
"faker": "^4.1.0",
8585
"loader.js": "^4.7.0",
86+
"match-json": "^1.3.0",
8687
"normalize.css": "^8.0.1",
8788
"nyc": "^15.0.0",
8889
"prettier": "^1.19.1",

tests/helpers/match-json.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* globals QUnit */
2+
3+
import match from 'match-json';
4+
5+
export default function registerMatchJsonAssertion() {
6+
QUnit.assert.matchJson = function(value, expected, message) {
7+
let result = match(value, expected);
8+
this.pushResult({ result, actual: value, expected, message });
9+
};
10+
}

tests/test-helper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import Application from '../app';
22
import config from '../config/environment';
33
import { setApplication } from '@ember/test-helpers';
44
import start from 'ember-exam/test-support/start';
5+
import registerMatchJsonAssertion from './helpers/match-json';
6+
7+
registerMatchJsonAssertion();
58

69
setApplication(Application.create(config.APP));
710

0 commit comments

Comments
 (0)