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
var testModule = require("./testModule"), | |
testModule2 = require('./testModule2'); | |
describe("mock/spy test", function() { | |
it("should not pass", function(done) { | |
var theNewValue = "this is a mock, sucker!" |
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
//If you need to spy or stub the global require function in node.js, don't try to spy on the require function itself..you aren't going //to be successful. | |
//Instead, spy on the require.extensions object like so: | |
var spies = {}; | |
spies.require = sinon.spy(require.extensions, '.js'); | |
//Then when you need to assert you can do stuff like: | |
spies.require.firstCall.args[1].should.include("path/to/some/module"); |
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
sebastian.flow("flows.examples.first") | |
.step("one", function() { | |
console.log("Welcome..."); | |
}) | |
.step("two", function() { | |
console.log("...to Sebastian."); | |
}) | |
.begin(); |
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
var userName = view.$el.find('#txtUserName').val(), | |
password = view.$el.find('#txtPassword').val(); | |
$.when(user.login()) | |
.done(function() { | |
$.when(user.fetch()) | |
.done(function() { | |
if (user.get("isAdmin")) { | |
view.showAdminPanel(); | |
} |
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
sebastian.flow("flows.examples.splash") | |
.step("get-form-data", function() { | |
var userName = this.view.$el.find('#txtUserName').val(), | |
password = this.view.$el.find('#txtPassword').val(); | |
return $.Deferred().resolve(userName, password); | |
}) | |
.step("login-user", function(userName, password) { | |
this.user.set("userName", userName); |
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
describe("flows.example.splash", function() { | |
describe("steps", function() { | |
describe("login-user", function() { | |
beforeEach(function() { | |
//Get the step | |
var target = sebastian.flow("flows.example.splash").step("login-user"), |
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
(function(root, enqueue) { | |
// Set up appropriately for the environment. | |
if (typeof exports !== 'undefined') { | |
// Node/CommonJS, need jQuery-deferred instead of regular jQuery | |
enqueue( | |
require('jquery-deferred'), | |
require("underscore"), | |
require('sinon'), | |
require('should'), | |
require('../sebastian').flow); |
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
// base path, that will be used to resolve files and exclude | |
basePath = ''; | |
// list of files / patterns to load in the browser | |
files = [ | |
MOCHA, | |
MOCHA_ADAPTER, | |
REQUIRE, | |
REQUIRE_ADAPTER, |
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
require.config({ | |
"baseUrl" : "/base", | |
//paths to the stuff Testacular has loaded into the server, but not included in the page | |
"paths" : { | |
"jquery" : "vendor/jquery/jquery", | |
"chai" : "vendor/chai/chai", | |
"underscore" : "vendor/underscore-amd/underscore", | |
"sinon" : "vendor/sinon/sinon" | |
}, | |
//Some shims.. |
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
mandarin@Tyrell:~/code/sebastian>mocha test/index.js | |
․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․ | |
✔ 66 tests complete (53 ms) |
OlderNewer