Javascript mocking library for unit testing ember-cli code
npm install ember-cli-jsmockitoJavascript Mocking and Matching Library for unit testing ember-cli applications.
ember-cli >= 0.1.4
npm install ember-cli-jsmockito --save-dev
`Add the following to
tests/.jshintrc inside the predef array.`
"mock",
"when",
"verify",
"mockFunction",
"spy",
"verifyZeroInteractions",
"verifyNoMoreInteractions",
"isMock",
"never",
"zeroInteractions",
"noMoreInteractions",
"times",
"once",
"empty",
"everyItem",
"hasItem",
"hasItems",
"hasSize",
"isIn",
"oneOf",
"allOf",
"anyOf",
"anything",
"both",
"either",
"equalTo",
"is",
"nil",
"not",
"raises",
"raisesAnything",
"sameAs",
"truth",
"equivalentMap",
"equivalentArray",
"between",
"closeTo",
"divisibleBy",
"even",
"greaterThan",
"greaterThanOrEqualTo",
"lessThan",
"lessThanOrEqualTo",
"notANumber",
"odd",
"zero",
"bool",
"func",
"hasFunction",
"hasMember",
"instanceOf",
"number",
"object",
"string",
"typeOf",
"containsString",
"emailAddress",
"endsWith",
"equalIgnoringCase",
"matches",
"startsWith"
`Features
$3
`javascript
assertThat('', empty());
assertThat('user@domain.com', emailAddress());
assertThat(10, either(greaterThan(50)).or(even()));
assertThat([1,2,3], everyItem(greaterThan(0)));
assertThat([1,2,3], hasSize(lessThan(5)));
`$3
`javascript
var modelMock = mock(DS.Model);
var controllerMock = mock(Ember.Controller);
`
$3
`javascript
var mockedFunc = mockFunction();
`
$3
`javascript
var employeeMock = mock(DS.Model);
when(employeeMock).get('name').thenReturn('jack');
equal('jack',employeeMock.get('name'));
`$3
`javascript
var mockedFunc = mockFunction();
mockedFunc('hello world');
verify(mockedFunc)('hello world');
``* Visit JsMockito for more information about mocking.
* Visit JsHamcrest for more information about the matching.