Detect monkey patching and emit a deprecation warning.
This isn't comprehensive but it should be broad enough to ensure that most people who would be affected by blocking monkey patching see a warning. Covers the jasmine namespace as well as classes that are monkey patched by zone.js. Replacing globals (describe/it/etc) doesn't trigger a warning because they belong to the user and are expected to be replaced.
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
describe('HtmlSpecFilter', function() {
|
||||
let env, deprecator;
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
|
||||
deprecator = jasmine.createSpyObj('deprecator', [
|
||||
'verboseDeprecations',
|
||||
'addDeprecationWarning'
|
||||
]);
|
||||
env = new privateUnderTest.Env({ deprecator });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
env.cleanup_();
|
||||
});
|
||||
|
||||
it('emits a deprecation warning', function() {
|
||||
new jasmineUnderTest.HtmlSpecFilter();
|
||||
expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith(
|
||||
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
|
||||
new jasmineUnderTest.HtmlSpecFilter({ env });
|
||||
expect(deprecator.addDeprecationWarning).toHaveBeenCalledWith(
|
||||
jasmine.anything(),
|
||||
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.',
|
||||
undefined
|
||||
);
|
||||
});
|
||||
|
||||
it('should match when no string is provided', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter();
|
||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter({ env });
|
||||
|
||||
expect(specFilter.matches('foo')).toBe(true);
|
||||
expect(specFilter.matches('*bar')).toBe(true);
|
||||
@@ -19,6 +31,7 @@ describe('HtmlSpecFilter', function() {
|
||||
|
||||
it('should only match the provided string', function() {
|
||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter({
|
||||
env,
|
||||
filterString: function() {
|
||||
return 'foo';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user