Made naming somewhat less confusing

This commit is contained in:
Steve Gravrock
2018-01-10 09:00:09 -08:00
parent 4934e420b2
commit 170a6dce76
2 changed files with 24 additions and 24 deletions

View File

@@ -111,23 +111,23 @@ describe("SpyStrategy", function() {
}); });
it("allows a custom strategy to be used", function() { it("allows a custom strategy to be used", function() {
var customStrategy = jasmine.createSpy('custom strategy') var plan = jasmine.createSpy('custom strategy')
.and.returnValue('custom strategy result'), .and.returnValue('custom strategy result'),
factory = jasmine.createSpy('custom strategy factory') customStrategy = jasmine.createSpy('custom strategy')
.and.returnValue(customStrategy), .and.returnValue(plan),
originalFn = jasmine.createSpy('original'), originalFn = jasmine.createSpy('original'),
spyStrategy = new jasmineUnderTest.SpyStrategy({ spyStrategy = new jasmineUnderTest.SpyStrategy({
fn: originalFn, fn: originalFn,
customStrategies: { customStrategies: {
doSomething: factory doSomething: customStrategy
} }
}); });
spyStrategy.doSomething(1, 2, 3); spyStrategy.doSomething(1, 2, 3);
expect(factory).toHaveBeenCalledWith(1, 2, 3); expect(customStrategy).toHaveBeenCalledWith(1, 2, 3);
expect(spyStrategy.exec(null, ['some', 'args'])) expect(spyStrategy.exec(null, ['some', 'args']))
.toEqual('custom strategy result'); .toEqual('custom strategy result');
expect(customStrategy).toHaveBeenCalledWith('some', 'args'); expect(plan).toHaveBeenCalledWith('some', 'args');
}); });
it("throws an error if a custom strategy doesn't return a function", function() { it("throws an error if a custom strategy doesn't return a function", function() {

View File

@@ -7,21 +7,21 @@ describe('Custom Spy Strategies (Integration)', function() {
}); });
it('allows adding more strategies local to a suite', function(done) { it('allows adding more strategies local to a suite', function(done) {
var strategyInstance = jasmine.createSpy('custom strategy instance') var plan = jasmine.createSpy('custom strategy plan')
.and.returnValue(42); .and.returnValue(42);
var strategyFactory = jasmine.createSpy('custom strategy factory') var strategy = jasmine.createSpy('custom strategy')
.and.returnValue(strategyInstance); .and.returnValue(plan);
env.describe('suite defining a custom spy strategy', function() { env.describe('suite defining a custom spy strategy', function() {
env.beforeEach(function() { env.beforeEach(function() {
env.addSpyStrategy('frobnicate', strategyFactory); env.addSpyStrategy('frobnicate', strategy);
}); });
env.it('spec in the suite', function() { env.it('spec in the suite', function() {
var spy = env.createSpy('something').and.frobnicate(17); var spy = env.createSpy('something').and.frobnicate(17);
expect(spy(1, 2, 3)).toEqual(42); expect(spy(1, 2, 3)).toEqual(42);
expect(strategyFactory).toHaveBeenCalledWith(17); expect(strategy).toHaveBeenCalledWith(17);
expect(strategyInstance).toHaveBeenCalledWith(1, 2, 3); expect(plan).toHaveBeenCalledWith(1, 2, 3);
}); });
}); });
@@ -39,17 +39,17 @@ describe('Custom Spy Strategies (Integration)', function() {
}); });
it('allows adding more strategies local to a spec', function(done) { it('allows adding more strategies local to a spec', function(done) {
var strategyInstance = jasmine.createSpy('custom strategy instance') var plan = jasmine.createSpy('custom strategy plan')
.and.returnValue(42); .and.returnValue(42);
var strategyFactory = jasmine.createSpy('custom strategy factory') var strategy = jasmine.createSpy('custom strategy')
.and.returnValue(strategyInstance); .and.returnValue(plan);
env.it('spec defining a custom spy strategy', function() { env.it('spec defining a custom spy strategy', function() {
env.addSpyStrategy('frobnicate', strategyFactory); env.addSpyStrategy('frobnicate', strategy);
var spy = env.createSpy('something').and.frobnicate(17); var spy = env.createSpy('something').and.frobnicate(17);
expect(spy(1, 2, 3)).toEqual(42); expect(spy(1, 2, 3)).toEqual(42);
expect(strategyFactory).toHaveBeenCalledWith(17); expect(strategy).toHaveBeenCalledWith(17);
expect(strategyInstance).toHaveBeenCalledWith(1, 2, 3); expect(plan).toHaveBeenCalledWith(1, 2, 3);
}); });
env.it('spec without custom strategy defined', function() { env.it('spec without custom strategy defined', function() {
@@ -66,21 +66,21 @@ describe('Custom Spy Strategies (Integration)', function() {
}); });
it('allows using custom strategies on a per-argument basis', function(done) { it('allows using custom strategies on a per-argument basis', function(done) {
var strategyInstance = jasmine.createSpy('custom strategy instance') var plan = jasmine.createSpy('custom strategy plan')
.and.returnValue(42); .and.returnValue(42);
var strategyFactory = jasmine.createSpy('custom strategy factory') var strategy = jasmine.createSpy('custom strategy')
.and.returnValue(strategyInstance); .and.returnValue(plan);
env.it('spec defining a custom spy strategy', function() { env.it('spec defining a custom spy strategy', function() {
env.addSpyStrategy('frobnicate', strategyFactory); env.addSpyStrategy('frobnicate', strategy);
var spy = env.createSpy('something') var spy = env.createSpy('something')
.and.returnValue('no args return') .and.returnValue('no args return')
.withArgs(1, 2, 3).and.frobnicate(17); .withArgs(1, 2, 3).and.frobnicate(17);
expect(spy()).toEqual('no args return'); expect(spy()).toEqual('no args return');
expect(strategyInstance).not.toHaveBeenCalled(); expect(plan).not.toHaveBeenCalled();
expect(spy(1, 2, 3)).toEqual(42); expect(spy(1, 2, 3)).toEqual(42);
expect(strategyInstance).toHaveBeenCalledWith(1, 2, 3); expect(plan).toHaveBeenCalledWith(1, 2, 3);
}); });
env.it('spec without custom strategy defined', function() { env.it('spec without custom strategy defined', function() {