Doc fixes. Really, markdown? Really?
This commit is contained in:
parent
2c8c3464b2
commit
9404716322
@ -93,7 +93,7 @@ Jasmine allows you to do this with `runs()` and `waits()` blocks.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
`runs()` blocks share functional scope -- `this` properties will be common to all blocks, but simple vars will not!
|
`runs()` blocks share functional scope -- `this` properties will be common to all blocks, but simple `vars` will not!
|
||||||
|
|
||||||
it('should be a test', function () {
|
it('should be a test', function () {
|
||||||
runs( function () {
|
runs( function () {
|
||||||
@ -205,17 +205,29 @@ There is a `Jasmine.Reporters` namespace for you to see how to handle reporting.
|
|||||||
Jasmine has several matchers:
|
Jasmine has several matchers:
|
||||||
|
|
||||||
`toEqual` compares objects or primitives and returns true if they are equal
|
`toEqual` compares objects or primitives and returns true if they are equal
|
||||||
|
|
||||||
`toNotEqual` compares objects or primitives and returns true if they are not equal
|
`toNotEqual` compares objects or primitives and returns true if they are not equal
|
||||||
|
|
||||||
`toMatch` takes a regex or a string and returns true if it matches
|
`toMatch` takes a regex or a string and returns true if it matches
|
||||||
|
|
||||||
`toNotMatch` takes a regex or a string and returns true if it does not match
|
`toNotMatch` takes a regex or a string and returns true if it does not match
|
||||||
|
|
||||||
`toBeDefined` returns true if the object or primitive is not `undefined`
|
`toBeDefined` returns true if the object or primitive is not `undefined`
|
||||||
|
|
||||||
`toBeNull` returns true if the object or primitive is not `null`
|
`toBeNull` returns true if the object or primitive is not `null`
|
||||||
|
|
||||||
`toBeTruthy` returns true if the object or primitive evaluates to true
|
`toBeTruthy` returns true if the object or primitive evaluates to true
|
||||||
|
|
||||||
`toBeFalsy` returns true if the object or primitive evaluates to false
|
`toBeFalsy` returns true if the object or primitive evaluates to false
|
||||||
|
|
||||||
`wasCalled` returns true if the object is a spy and was called
|
`wasCalled` returns true if the object is a spy and was called
|
||||||
|
|
||||||
`wasNotCalled` returns true if the object is a spy and was not called
|
`wasNotCalled` returns true if the object is a spy and was not called
|
||||||
|
|
||||||
`wasNotCalledWith` returns true if the object is a spy and was called with the passed arguments
|
`wasNotCalledWith` returns true if the object is a spy and was called with the passed arguments
|
||||||
|
|
||||||
`toContain` returns true if an array or string contains the passed variable.
|
`toContain` returns true if an array or string contains the passed variable.
|
||||||
|
|
||||||
`toNotContain` returns true if an array or string does not contain the passed variable.
|
`toNotContain` returns true if an array or string does not contain the passed variable.
|
||||||
|
|
||||||
### Writing new Matchers
|
### Writing new Matchers
|
||||||
@ -274,7 +286,7 @@ describe('some suite', function () {
|
|||||||
|
|
||||||
Jasmine integrates 'spies' that permit many spying, mocking, and faking behaviors.
|
Jasmine integrates 'spies' that permit many spying, mocking, and faking behaviors.
|
||||||
|
|
||||||
Here is an few examples:
|
Here are a few examples:
|
||||||
|
|
||||||
var Klass = function () {
|
var Klass = function () {
|
||||||
}
|
}
|
||||||
@ -294,22 +306,28 @@ it('should spy on Klass#method') {
|
|||||||
spyOn(Klass, 'method');
|
spyOn(Klass, 'method');
|
||||||
Klass.method('foo argument');
|
Klass.method('foo argument');
|
||||||
expect(Klass.method).wasCalledWith('foo argument');
|
expect(Klass.method).wasCalledWith('foo argument');
|
||||||
}
|
});
|
||||||
|
|
||||||
it('should spy on Klass#methodWithCallback') {
|
it('should spy on Klass#methodWithCallback') {
|
||||||
var callback = Jasmine.createSpy();
|
var callback = Jasmine.createSpy();
|
||||||
Klass.method(callback);
|
Klass.method(callback);
|
||||||
expect(callback).wasCalledWith('foo');
|
expect(callback).wasCalledWith('foo');
|
||||||
}
|
});
|
||||||
|
|
||||||
Many other options are available for spies:
|
Many other options are available for spies:
|
||||||
|
|
||||||
`andCallThrough()`: spies on AND calls the original function spied on
|
`andCallThrough()`: spies on AND calls the original function spied on
|
||||||
|
|
||||||
`andReturn()`: returns passed arguments when spy is called
|
`andReturn()`: returns passed arguments when spy is called
|
||||||
|
|
||||||
`andThrow()`: throws passed exception when spy is called
|
`andThrow()`: throws passed exception when spy is called
|
||||||
|
|
||||||
`andCallFake()`: calls passed function when spy is called
|
`andCallFake()`: calls passed function when spy is called
|
||||||
|
|
||||||
`callCount`: returns number of times spy was called
|
`callCount`: returns number of times spy was called
|
||||||
|
|
||||||
`mostRecentCall.args`: returns argument array from last call to spy.
|
`mostRecentCall.args`: returns argument array from last call to spy.
|
||||||
|
|
||||||
`argsForCall[i]` returns arguments array for call `i` to spy.
|
`argsForCall[i]` returns arguments array for call `i` to spy.
|
||||||
|
|
||||||
Spies are automatically removed after each spec. They may be set in the beforeEach function.
|
Spies are automatically removed after each spec. They may be set in the beforeEach function.
|
||||||
|
Loading…
Reference in New Issue
Block a user