diff --git a/src/__tests__/__snapshots__/mountSpec.js.snap b/src/__tests__/__snapshots__/mountSpec.js.snap
new file mode 100644
index 0000000..6a62f44
--- /dev/null
+++ b/src/__tests__/__snapshots__/mountSpec.js.snap
@@ -0,0 +1,97 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`UIAtoms mount rendering should render atoms with noscript tag - disabled by $Settings, overriden by props: Iframe without noscript tag 1`] = `
+"
"
+`;
+
+exports[`UIAtoms mount rendering should render atoms with noscript tag - disabled by $Settings, overriden by props: Image without noscript tag 1`] = `
+""
+`;
+
+exports[`UIAtoms mount rendering should render atoms with noscript tag - disabled by $Settings, overriden by props: Video without noscript tag 1`] = `
+""
+`;
+
+exports[`UIAtoms mount rendering should render atoms with noscript tag: should render Iframe with noscript tag 1`] = `
+""
+`;
+
+exports[`UIAtoms mount rendering should render atoms with noscript tag: should render Image with noscript tag 1`] = `
+""
+`;
+
+exports[`UIAtoms mount rendering should render atoms with noscript tag: should render Video with noscript tag 1`] = `
+""
+`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - disabled by $Settings: Iframe without noscript tag 1`] = `""`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - disabled by $Settings: Image without noscript tag 1`] = `""`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - disabled by $Settings: Video without noscript tag 1`] = `""`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - disabled by props: Iframe without noscript tag 1`] = `""`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - disabled by props: Image without noscript tag 1`] = `""`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - disabled by props: Video without noscript tag 1`] = `""`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - enabled by $Settings, overriden by props: Iframe without noscript tag 1`] = `""`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - enabled by $Settings, overriden by props: Image without noscript tag 1`] = `""`;
+
+exports[`UIAtoms mount rendering should render atoms without noscript tag - enabled by $Settings, overriden by props: Video without noscript tag 1`] = `""`;
diff --git a/src/__tests__/mountSpec.js b/src/__tests__/mountSpec.js
new file mode 100644
index 0000000..5794d1e
--- /dev/null
+++ b/src/__tests__/mountSpec.js
@@ -0,0 +1,288 @@
+import { mount } from 'enzyme';
+import React from 'react';
+import PropTypes from 'prop-types';
+import { toMockedInstance } from 'to-mock';
+import classnames from 'classnames';
+
+import * as UIAtoms from '../main';
+import UIComponentHelper from '../UIComponentHelper';
+import ComponentPositions from '../ComponentPositions';
+import Visibility from '../Visibility';
+import { Infinite } from 'infinite-circle';
+
+import { JSDOM } from 'jsdom';
+const jsdom = new JSDOM('');
+const { window } = jsdom;
+
+import _router from '../mocks/router';
+import _window from '../mocks/window';
+import _settings from '../mocks/settings';
+
+global.window = window;
+global.document = window.document;
+global.navigator = {
+ userAgent: 'node.js'
+};
+
+const visibility = toMockedInstance(Visibility);
+const mockPosition = {
+ height: 0
+};
+const componentPositions = toMockedInstance(ComponentPositions, {
+ getWindowViewportRect: () => mockPosition
+});
+const infinite = toMockedInstance(Infinite);
+
+const childContextTypes = {
+ $Utils: PropTypes.shape({}),
+ $Settings: PropTypes.shape({})
+};
+
+function getComponentOptions(overrideSettings = {}) {
+ const $Settings = Object.assign({}, _settings, overrideSettings);
+
+ const $UIComponentHelper = new UIComponentHelper(
+ _router,
+ _window,
+ componentPositions,
+ visibility,
+ infinite,
+ classnames,
+ $Settings
+ );
+
+ const context = {
+ $Utils: {
+ $Settings,
+ $UIComponentHelper
+ }
+ };
+ const mountOptions = {
+ context,
+ childContextTypes,
+ someProp: true
+ };
+
+ return mountOptions;
+}
+
+describe('UIAtoms mount rendering', () => {
+ let wrapper = null;
+
+ afterEach(() => {
+ if (wrapper) {
+ wrapper.unmount();
+ }
+ });
+
+ describe('should render atoms with noscript tag: ', () => {
+ let mountOptions = getComponentOptions();
+
+ it('should render Image with noscript tag', () => {
+ const Component = UIAtoms.Image;
+ wrapper = mount(, mountOptions);
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(1);
+ });
+
+ it('should render Video with noscript tag', () => {
+ const Component = UIAtoms.Video;
+ wrapper = mount(, mountOptions);
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(1);
+ });
+
+ it('should render Iframe with noscript tag', () => {
+ const Component = UIAtoms.Iframe;
+ wrapper = mount(, mountOptions);
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(1);
+ });
+ });
+
+ describe('should render atoms without noscript tag - disabled by props: ', () => {
+ let mountOptions = getComponentOptions();
+
+ it('Image without noscript tag', () => {
+ const Component = UIAtoms.Image;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+
+ it('Video without noscript tag', () => {
+ const Component = UIAtoms.Video;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+
+ it('Iframe without noscript tag', () => {
+ const Component = UIAtoms.Iframe;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+ });
+
+ describe('should render atoms without noscript tag - disabled by $Settings: ', () => {
+ let mountOptions = getComponentOptions({
+ plugin: {
+ imaUiAtoms: {
+ useIntersectionObserver: {
+ iframes: true,
+ images: true,
+ videos: true
+ },
+ disableNoScript: {
+ iframes: true,
+ images: true,
+ videos: true
+ }
+ }
+ }
+ });
+
+ it('Image without noscript tag', () => {
+ const Component = UIAtoms.Image;
+ wrapper = mount(, mountOptions);
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+ it('Video without noscript tag', () => {
+ const Component = UIAtoms.Video;
+ wrapper = mount(, mountOptions);
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+
+ it('Iframe without noscript tag', () => {
+ const Component = UIAtoms.Iframe;
+ wrapper = mount(, mountOptions);
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+ });
+
+ describe('should render atoms with noscript tag - disabled by $Settings, overriden by props: ', () => {
+ let mountOptions = getComponentOptions({
+ plugin: {
+ imaUiAtoms: {
+ useIntersectionObserver: {
+ iframes: true,
+ images: true,
+ videos: true
+ },
+ disableNoScript: {
+ iframes: true,
+ images: true,
+ videos: true
+ }
+ }
+ }
+ });
+
+ it('Image without noscript tag', () => {
+ const Component = UIAtoms.Image;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(1);
+ });
+
+ it('Video without noscript tag', () => {
+ const Component = UIAtoms.Video;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(1);
+ });
+
+ it('Iframe without noscript tag', () => {
+ const Component = UIAtoms.Iframe;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(1);
+ });
+ });
+
+ describe('should render atoms without noscript tag - enabled by $Settings, overriden by props: ', () => {
+ let mountOptions = getComponentOptions({
+ plugin: {
+ imaUiAtoms: {
+ useIntersectionObserver: {
+ iframes: true,
+ images: true,
+ videos: true
+ },
+ disableNoScript: {
+ iframes: false,
+ images: false,
+ videos: false
+ }
+ }
+ }
+ });
+
+ it('Image without noscript tag', () => {
+ const Component = UIAtoms.Image;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+
+ it('Video without noscript tag', () => {
+ const Component = UIAtoms.Video;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+
+ it('Iframe without noscript tag', () => {
+ const Component = UIAtoms.Iframe;
+ wrapper = mount(
+ ,
+ mountOptions
+ );
+
+ expect(wrapper.html()).toMatchSnapshot();
+ expect(wrapper.find('noscript').length).toEqual(0);
+ });
+ });
+});
diff --git a/src/iframe/HtmlIframe.jsx b/src/iframe/HtmlIframe.jsx
index 3b5ebf0..cc3cb28 100644
--- a/src/iframe/HtmlIframe.jsx
+++ b/src/iframe/HtmlIframe.jsx
@@ -35,6 +35,9 @@ export default class HtmlIframe extends React.PureComponent {
this._onVisibilityWriter = this.onVisibilityWriter.bind(this);
this._rootElement = React.createRef();
+
+ this._helper = this.utils.$UIComponentHelper;
+ this._settings = this.utils.$Settings;
}
get utils() {
@@ -42,14 +45,20 @@ export default class HtmlIframe extends React.PureComponent {
}
get useIntersectionObserver() {
- return !(
- this.utils.$Settings &&
- this.utils.$Settings.plugin &&
- this.utils.$Settings.plugin.imaUiAtoms &&
- this.utils.$Settings.plugin.imaUiAtoms.useIntersectionObserver &&
- this.utils.$Settings.plugin.imaUiAtoms.useIntersectionObserver.iframes ===
- false
- );
+ return this.props.useIntersectionObserver !== undefined
+ ? this.props.useIntersectionObserver
+ : this._settings.plugin.imaUiAtoms.useIntersectionObserver.iframes !==
+ undefined
+ ? this._settings.plugin.imaUiAtoms.useIntersectionObserver.iframes
+ : this._settings.plugin.imaUiAtoms.useIntersectionObserver;
+ }
+
+ get disableNoScript() {
+ return this.props.disableNoScript !== undefined
+ ? this.props.disableNoScript
+ : this._settings.plugin.imaUiAtoms.disableNoScript.iframes !== undefined
+ ? this._settings.plugin.imaUiAtoms.disableNoScript.iframes
+ : this._settings.plugin.imaUiAtoms.disableNoScript;
}
componentDidMount() {
@@ -63,12 +72,10 @@ export default class HtmlIframe extends React.PureComponent {
}
render() {
- let helper = this.utils.$UIComponentHelper;
-
return (