Deprecated access to non-public members in specs and suites returned from it(), describe(), etc.
This commit is contained in:
@@ -2155,7 +2155,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
'Please either remove the describe or add children to it.'
|
||||
);
|
||||
}
|
||||
return suite;
|
||||
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
|
||||
};
|
||||
|
||||
this.xdescribe = function(description, specDefinitions) {
|
||||
@@ -2164,7 +2164,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
var suite = suiteFactory(description);
|
||||
suite.pend();
|
||||
addSpecsToSuite(suite, specDefinitions);
|
||||
return suite;
|
||||
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
|
||||
};
|
||||
|
||||
var focusedRunnables = [];
|
||||
@@ -2179,7 +2179,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
unfocusAncestor();
|
||||
addSpecsToSuite(suite, specDefinitions);
|
||||
|
||||
return suite;
|
||||
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
|
||||
};
|
||||
|
||||
function addSpecsToSuite(suite, specDefinitions) {
|
||||
@@ -2269,7 +2269,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
this.it = function(description, fn, timeout) {
|
||||
this.it_ = function(description, fn, timeout) {
|
||||
ensureIsNotNested('it');
|
||||
// it() sometimes doesn't have a fn argument, so only check the type if
|
||||
// it's given.
|
||||
@@ -2281,9 +2281,15 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
spec.pend();
|
||||
}
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
|
||||
return spec;
|
||||
};
|
||||
|
||||
this.it = function(description, fn, timeout) {
|
||||
var spec = this.it_(description, fn, timeout);
|
||||
return j$.deprecatingSpecProxy(spec, this);
|
||||
};
|
||||
|
||||
this.xit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('xit');
|
||||
// xit(), like it(), doesn't always have a fn argument, so only check the
|
||||
@@ -2291,9 +2297,9 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
if (arguments.length > 1 && typeof fn !== 'undefined') {
|
||||
ensureIsFunctionOrAsync(fn, 'xit');
|
||||
}
|
||||
var spec = this.it.apply(this, arguments);
|
||||
var spec = this.it_.apply(this, arguments);
|
||||
spec.pend('Temporarily disabled with xit');
|
||||
return spec;
|
||||
return j$.deprecatingSpecProxy(spec, this);
|
||||
};
|
||||
|
||||
this.fit = function(description, fn, timeout) {
|
||||
@@ -2303,7 +2309,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
focusedRunnables.push(spec.id);
|
||||
unfocusAncestor();
|
||||
return spec;
|
||||
return j$.deprecatingSpecProxy(spec, this);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3744,7 +3750,7 @@ getJasmineRequireObj().deprecatingSpecProxy = function(j$) {
|
||||
return (
|
||||
'Access to private Spec members (in this case `' +
|
||||
memberName +
|
||||
'`) via Env#topSuite is not supported and will break in ' +
|
||||
'`) is not supported and will break in ' +
|
||||
'a future release. See <https://jasmine.github.io/api/edge/Spec.html> ' +
|
||||
'for correct usage.'
|
||||
);
|
||||
@@ -3823,7 +3829,7 @@ getJasmineRequireObj().deprecatingSuiteProxy = function(j$) {
|
||||
return (
|
||||
'Access to private Suite members (in this case `' +
|
||||
memberName +
|
||||
'`) via Env#topSuite is not supported and will break in ' +
|
||||
'`) is not supported and will break in ' +
|
||||
'a future release. See <https://jasmine.github.io/api/edge/Suite.html> ' +
|
||||
'for correct usage.'
|
||||
);
|
||||
|
||||
@@ -106,7 +106,91 @@ describe('Env', function() {
|
||||
expect(env.deprecated).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('deprecates access to internal Suite and Spec members', function() {
|
||||
it('deprecates access to internal Spec members via it(), fit(), and xit()', function() {
|
||||
jasmine.getEnv().requireProxy();
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
['it', 'fit', 'xit'].forEach(function(method) {
|
||||
var spec = env[method]('a spec', function() {});
|
||||
expect(env.deprecated).not.toHaveBeenCalled();
|
||||
|
||||
spec.pend();
|
||||
expect(env.deprecated)
|
||||
.withContext('via ' + method)
|
||||
.toHaveBeenCalledWith(
|
||||
'Access to private Spec members (in this case `pend`) is not ' +
|
||||
'supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
|
||||
);
|
||||
env.deprecated.calls.reset();
|
||||
|
||||
spec.expectationFactory = {};
|
||||
expect(env.deprecated)
|
||||
.withContext('via ' + method)
|
||||
.toHaveBeenCalledWith(
|
||||
'Access to private Spec members (in this case `expectationFactory`) is not ' +
|
||||
'supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
|
||||
);
|
||||
env.deprecated.calls.reset();
|
||||
|
||||
spec.expectationFactory = {};
|
||||
expect(env.deprecated)
|
||||
.withContext('via ' + method)
|
||||
.toHaveBeenCalledWith(
|
||||
'Access to private Spec members (in this case `expectationFactory`) is not ' +
|
||||
'supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
|
||||
);
|
||||
env.deprecated.calls.reset();
|
||||
});
|
||||
});
|
||||
|
||||
it('deprecates access to internal Spec and Suite members via describe(), fdescribe(), and xdescribe()', function() {
|
||||
jasmine.getEnv().requireProxy();
|
||||
spyOn(env, 'deprecated');
|
||||
|
||||
['describe', 'fdescribe', 'xdescribe'].forEach(function(method) {
|
||||
var suite = env[method]('a suite', function() {
|
||||
env.it('a spec');
|
||||
});
|
||||
|
||||
suite.expectationFactory;
|
||||
expect(env.deprecated)
|
||||
.withContext('via ' + method)
|
||||
.toHaveBeenCalledWith(
|
||||
'Access to private Suite ' +
|
||||
'members (in this case `expectationFactory`) is ' +
|
||||
'not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
|
||||
);
|
||||
env.deprecated.calls.reset();
|
||||
|
||||
suite.expectationFactory = {};
|
||||
expect(env.deprecated)
|
||||
.withContext('via ' + method)
|
||||
.toHaveBeenCalledWith(
|
||||
'Access to private Suite ' +
|
||||
'members (in this case `expectationFactory`) is ' +
|
||||
'not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
|
||||
);
|
||||
env.deprecated.calls.reset();
|
||||
|
||||
suite.status();
|
||||
expect(env.deprecated)
|
||||
.withContext('via ' + method)
|
||||
.toHaveBeenCalledWith(
|
||||
'Access to private Suite ' +
|
||||
'members (in this case `status`) is ' +
|
||||
'not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
|
||||
);
|
||||
env.deprecated.calls.reset();
|
||||
});
|
||||
});
|
||||
|
||||
it('deprecates access to internal Suite and Spec members via topSuite', function() {
|
||||
jasmine.getEnv().requireProxy();
|
||||
var topSuite, expectationFactory, spec;
|
||||
|
||||
@@ -117,7 +201,7 @@ describe('Env', function() {
|
||||
topSuite.expectationFactory;
|
||||
expect(env.deprecated).toHaveBeenCalledWith(
|
||||
'Access to private Suite ' +
|
||||
'members (in this case `expectationFactory`) via Env#topSuite is ' +
|
||||
'members (in this case `expectationFactory`) is ' +
|
||||
'not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
|
||||
);
|
||||
@@ -126,7 +210,7 @@ describe('Env', function() {
|
||||
topSuite.expectationFactory = expectationFactory;
|
||||
expect(env.deprecated).toHaveBeenCalledWith(
|
||||
'Access to private Suite ' +
|
||||
'members (in this case `expectationFactory`) via Env#topSuite is ' +
|
||||
'members (in this case `expectationFactory`) is ' +
|
||||
'not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
|
||||
);
|
||||
@@ -134,7 +218,7 @@ describe('Env', function() {
|
||||
topSuite.status();
|
||||
expect(env.deprecated).toHaveBeenCalledWith(
|
||||
'Access to private Suite ' +
|
||||
'members (in this case `status`) via Env#topSuite is ' +
|
||||
'members (in this case `status`) is ' +
|
||||
'not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
|
||||
);
|
||||
@@ -143,7 +227,7 @@ describe('Env', function() {
|
||||
spec.pend();
|
||||
expect(env.deprecated).toHaveBeenCalledWith(
|
||||
'Access to private Spec ' +
|
||||
'members (in this case `pend`) via Env#topSuite ' +
|
||||
'members (in this case `pend`) ' +
|
||||
'is not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
|
||||
);
|
||||
@@ -151,7 +235,7 @@ describe('Env', function() {
|
||||
expectationFactory = spec.expectationFactory;
|
||||
expect(env.deprecated).toHaveBeenCalledWith(
|
||||
'Access to private Spec ' +
|
||||
'members (in this case `expectationFactory`) via Env#topSuite ' +
|
||||
'members (in this case `expectationFactory`) ' +
|
||||
'is not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
|
||||
);
|
||||
@@ -160,7 +244,7 @@ describe('Env', function() {
|
||||
spec.expectationFactory = expectationFactory;
|
||||
expect(env.deprecated).toHaveBeenCalledWith(
|
||||
'Access to private Spec ' +
|
||||
'members (in this case `expectationFactory`) via Env#topSuite ' +
|
||||
'members (in this case `expectationFactory`) ' +
|
||||
'is not supported and will break in a future release. See ' +
|
||||
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
|
||||
);
|
||||
@@ -347,7 +431,7 @@ describe('Env', function() {
|
||||
describe('#xit', function() {
|
||||
it('calls spec.pend with "Temporarily disabled with xit"', function() {
|
||||
var pendSpy = jasmine.createSpy();
|
||||
spyOn(env, 'it').and.returnValue({
|
||||
spyOn(env, 'it_').and.returnValue({
|
||||
pend: pendSpy
|
||||
});
|
||||
env.xit('foo', function() {});
|
||||
|
||||
@@ -550,10 +550,17 @@ describe('spec running', function() {
|
||||
var pendingSpec,
|
||||
suite = env.describe('default current suite', function() {
|
||||
pendingSpec = env.it('I am a pending spec');
|
||||
});
|
||||
}),
|
||||
reporter = jasmine.createSpyObj('reporter', ['specDone']);
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(pendingSpec.status()).toBe('pending');
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
status: 'pending'
|
||||
})
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1117,7 +1117,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
'Please either remove the describe or add children to it.'
|
||||
);
|
||||
}
|
||||
return suite;
|
||||
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
|
||||
};
|
||||
|
||||
this.xdescribe = function(description, specDefinitions) {
|
||||
@@ -1126,7 +1126,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
var suite = suiteFactory(description);
|
||||
suite.pend();
|
||||
addSpecsToSuite(suite, specDefinitions);
|
||||
return suite;
|
||||
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
|
||||
};
|
||||
|
||||
var focusedRunnables = [];
|
||||
@@ -1141,7 +1141,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
unfocusAncestor();
|
||||
addSpecsToSuite(suite, specDefinitions);
|
||||
|
||||
return suite;
|
||||
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
|
||||
};
|
||||
|
||||
function addSpecsToSuite(suite, specDefinitions) {
|
||||
@@ -1231,7 +1231,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
this.it = function(description, fn, timeout) {
|
||||
this.it_ = function(description, fn, timeout) {
|
||||
ensureIsNotNested('it');
|
||||
// it() sometimes doesn't have a fn argument, so only check the type if
|
||||
// it's given.
|
||||
@@ -1243,9 +1243,15 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
spec.pend();
|
||||
}
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
|
||||
return spec;
|
||||
};
|
||||
|
||||
this.it = function(description, fn, timeout) {
|
||||
var spec = this.it_(description, fn, timeout);
|
||||
return j$.deprecatingSpecProxy(spec, this);
|
||||
};
|
||||
|
||||
this.xit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('xit');
|
||||
// xit(), like it(), doesn't always have a fn argument, so only check the
|
||||
@@ -1253,9 +1259,9 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
if (arguments.length > 1 && typeof fn !== 'undefined') {
|
||||
ensureIsFunctionOrAsync(fn, 'xit');
|
||||
}
|
||||
var spec = this.it.apply(this, arguments);
|
||||
var spec = this.it_.apply(this, arguments);
|
||||
spec.pend('Temporarily disabled with xit');
|
||||
return spec;
|
||||
return j$.deprecatingSpecProxy(spec, this);
|
||||
};
|
||||
|
||||
this.fit = function(description, fn, timeout) {
|
||||
@@ -1265,7 +1271,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
focusedRunnables.push(spec.id);
|
||||
unfocusAncestor();
|
||||
return spec;
|
||||
return j$.deprecatingSpecProxy(spec, this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ getJasmineRequireObj().deprecatingSpecProxy = function(j$) {
|
||||
return (
|
||||
'Access to private Spec members (in this case `' +
|
||||
memberName +
|
||||
'`) via Env#topSuite is not supported and will break in ' +
|
||||
'`) is not supported and will break in ' +
|
||||
'a future release. See <https://jasmine.github.io/api/edge/Spec.html> ' +
|
||||
'for correct usage.'
|
||||
);
|
||||
|
||||
@@ -25,7 +25,7 @@ getJasmineRequireObj().deprecatingSuiteProxy = function(j$) {
|
||||
return (
|
||||
'Access to private Suite members (in this case `' +
|
||||
memberName +
|
||||
'`) via Env#topSuite is not supported and will break in ' +
|
||||
'`) is not supported and will break in ' +
|
||||
'a future release. See <https://jasmine.github.io/api/edge/Suite.html> ' +
|
||||
'for correct usage.'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user