Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amp-script: remove all console errors from tests #27459

Merged
merged 1 commit into from Mar 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions extensions/amp-script/0.1/test/unit/test-amp-script.js
Expand Up @@ -23,6 +23,10 @@ import {
} from '../../amp-script';
import {FakeWindow} from '../../../../../testing/fake-dom';
import {Services} from '../../../../../src/services';
import {
registerServiceBuilderForDoc,
resetServiceForTesting,
} from '../../../../../src/service';
import {user} from '../../../../../src/log';

describes.fakeWin('AmpScript', {amp: {runtimeOn: false}}, env => {
Expand Down Expand Up @@ -76,6 +80,7 @@ describes.fakeWin('AmpScript', {amp: {runtimeOn: false}}, env => {
'alert(1)'
);

expectAsyncConsoleError(/Same-origin "src" requires/);
return script.layoutCallback().should.be.rejected;
});

Expand All @@ -89,6 +94,7 @@ describes.fakeWin('AmpScript', {amp: {runtimeOn: false}}, env => {
'alert(1)'
);

expectAsyncConsoleError(/should require JS content-type/);
return script.layoutCallback().should.be.fulfilled;
});

Expand Down Expand Up @@ -197,6 +203,17 @@ describes.fakeWin('AmpScript', {amp: {runtimeOn: false}}, env => {
});

describe('development mode', () => {
beforeEach(() => {
registerServiceBuilderForDoc(
env.win.document,
'amp-script',
AmpScriptService
);
});
afterEach(() => {
resetServiceForTesting(env.win, 'amp-script');
});

it('should not be in dev mode by default', () => {
script.buildCallback();
expect(script.development_).false;
Expand Down Expand Up @@ -266,6 +283,7 @@ describes.repeated(
});

it('should reject if hash does not exist in meta tag', () => {
expectAsyncConsoleError(/Script hash not found/);
createMetaHash('amp-script-src', 'sha384-another_fake_hash');

service = new AmpScriptService(env.ampdoc);
Expand Down Expand Up @@ -541,6 +559,7 @@ describe('SanitizerImpl', () => {
});

it('AMP.setState(not_json)', async () => {
expectAsyncConsoleError(/Invalid AMP.setState/);
await s.setStorage(
StorageLocation.AMP_STATE,
/* key */ null,
Expand Down