-
-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add release documentation for v8.0.0
- Loading branch information
Showing
36 changed files
with
3,538 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require("@fatso83/mini-mocha").install(); | ||
var sinon = require("sinon"); | ||
var PubSub = require("pubsub-js"); | ||
var referee = require("@sinonjs/referee"); | ||
var assertTrue = referee.assert; | ||
|
||
describe('PubSub', function() { | ||
it("should call subscribers on publish", function () { | ||
var callback = sinon.spy(); | ||
|
||
PubSub.subscribe("message", callback); | ||
PubSub.publishSync("message"); | ||
|
||
assertTrue(callback.called); | ||
}) | ||
}); |
31 changes: 31 additions & 0 deletions
31
docs/_releases/latest/examples/spies-2-wrap-object-methods.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require("@fatso83/mini-mocha").install(); | ||
var sinon = require("sinon"); | ||
var referee = require("@sinonjs/referee"); | ||
var assert = referee.assert; | ||
var jsdom = require('jsdom'); | ||
var JSDOM = jsdom.JSDOM; | ||
var window = (new JSDOM()).window; | ||
var document = (new JSDOM('')).window; | ||
var jQuery = require('jquery')(window); | ||
global.document = document; | ||
|
||
describe('Wrap all object method', function() { | ||
var sandbox = sinon.createSandbox(); | ||
|
||
beforeEach(function() { | ||
sandbox.spy(jQuery); | ||
}); | ||
|
||
afterEach(function() { | ||
sandbox.restore(); | ||
}); | ||
|
||
it("should inspect jQuery.getJSON's usage of jQuery.ajax", function () { | ||
var url = "https://jsonplaceholder.typicode.com/todos/1"; | ||
jQuery.getJSON(url); | ||
|
||
assert(jQuery.ajax.calledOnce); | ||
assert.equals(url, jQuery.ajax.getCall(0).args[0].url); | ||
assert.equals("json", jQuery.ajax.getCall(0).args[0].dataType); | ||
}) | ||
}); |
31 changes: 31 additions & 0 deletions
31
docs/_releases/latest/examples/spies-3-wrap-existing-method.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require("@fatso83/mini-mocha").install(); | ||
var sinon = require("sinon"); | ||
var referee = require("@sinonjs/referee"); | ||
var assert = referee.assert; | ||
var jsdom = require('jsdom'); | ||
var JSDOM = jsdom.JSDOM; | ||
var window = (new JSDOM()).window; | ||
var document = (new JSDOM('')).window; | ||
var jQuery = require('jquery')(window); | ||
global.document = document; | ||
|
||
describe('Wrap existing method', function() { | ||
var sandbox = sinon.createSandbox(); | ||
|
||
beforeEach(function() { | ||
sandbox.spy(jQuery, "ajax"); | ||
}); | ||
|
||
afterEach(function() { | ||
sandbox.restore(); | ||
}); | ||
|
||
it("should inspect jQuery.getJSON's usage of jQuery.ajax", function () { | ||
var url = "https://jsonplaceholder.typicode.com/todos/1"; | ||
jQuery.getJSON(url); | ||
|
||
assert(jQuery.ajax.calledOnce); | ||
assert.equals(url, jQuery.ajax.getCall(0).args[0].url); | ||
assert.equals("json", jQuery.ajax.getCall(0).args[0].dataType); | ||
}) | ||
}); |
17 changes: 17 additions & 0 deletions
17
docs/_releases/latest/examples/spies-4-pubsub-message-1.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require("@fatso83/mini-mocha").install(); | ||
var sinon = require("sinon"); | ||
var PubSub = require("pubsub-js"); | ||
var referee = require("@sinonjs/referee"); | ||
var assert = referee.assert; | ||
|
||
describe('PubSub', function() { | ||
it("should call subscribers with message as first argument", function () { | ||
var message = 'an example message'; | ||
var spy = sinon.spy(); | ||
|
||
PubSub.subscribe(message, spy); | ||
PubSub.publishSync(message, "some payload"); | ||
|
||
assert(spy.calledWith(message)); | ||
}) | ||
}); |
17 changes: 17 additions & 0 deletions
17
docs/_releases/latest/examples/spies-5-pubsub-message-2.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require("@fatso83/mini-mocha").install(); | ||
var sinon = require("sinon"); | ||
var PubSub = require("pubsub-js"); | ||
var referee = require("@sinonjs/referee"); | ||
var assert = referee.assert; | ||
|
||
describe('PubSub', function() { | ||
it("should call subscribers with message as first argument", function () { | ||
var message = 'an example message'; | ||
var spy = sinon.spy(); | ||
|
||
PubSub.subscribe(message, spy); | ||
PubSub.publishSync(message, "some payload"); | ||
|
||
assert.equals(message, spy.args[0][0]); | ||
}) | ||
}); |
17 changes: 17 additions & 0 deletions
17
docs/_releases/latest/examples/spies-6-pubsub-message-3.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require("@fatso83/mini-mocha").install(); | ||
var sinon = require("sinon"); | ||
var PubSub = require("pubsub-js"); | ||
var referee = require("@sinonjs/referee"); | ||
var assert = referee.assert; | ||
|
||
describe('PubSub', function() { | ||
it("should call subscribers with message as first argument", function () { | ||
var message = 'an example message'; | ||
var spy = sinon.spy(); | ||
|
||
PubSub.subscribe(message, spy); | ||
PubSub.publishSync(message, "some payload"); | ||
|
||
assert.equals(message, spy.getCall(0).args[0]); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require("@fatso83/mini-mocha").install(); | ||
var sinon = require("sinon"); | ||
var referee = require("@sinonjs/referee"); | ||
var assert = referee.assert; | ||
|
||
describe('withArgs', function() { | ||
it("should call method once with each argument", function () { | ||
var object = { method: function () {} }; | ||
var spy = sinon.spy(object, "method"); | ||
|
||
object.method(42); | ||
object.method(1); | ||
|
||
assert(spy.withArgs(42).calledOnce); | ||
assert(spy.withArgs(1).calledOnce); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require("@fatso83/mini-mocha").install(); | ||
var sinon = require("sinon"); | ||
var referee = require("@sinonjs/referee"); | ||
var assert = referee.assert; | ||
var jsdom = require('jsdom'); | ||
var JSDOM = jsdom.JSDOM; | ||
var window = (new JSDOM()).window; | ||
var document = (new JSDOM('')).window; | ||
var jQuery = require('jquery')(window); | ||
global.document = document; | ||
|
||
describe('Return nth call', function() { | ||
var sandbox = sinon.createSandbox(); | ||
|
||
beforeEach(function() { | ||
sandbox.spy(jQuery, "ajax"); | ||
}); | ||
|
||
afterEach(function() { | ||
sandbox.restore(); | ||
}); | ||
|
||
it("should inspect jQuery.getJSON's usage of jQuery.ajax", function () { | ||
var url = "https://jsonplaceholder.typicode.com/todos/1"; | ||
jQuery.ajax(url); | ||
var spyCall = jQuery.ajax.getCall(0); | ||
|
||
assert.equals(url, spyCall.args[0]); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.