mirror of
https://github.com/Safe-Support-Chat/ocrcc-chatbox
synced 2024-11-22 10:44:54 +00:00
fixing tests for changed bookmark
This commit is contained in:
parent
81517491d5
commit
bf5c6d597a
@ -4,7 +4,8 @@ import Adapter from 'enzyme-adapter-react-16';
|
|||||||
Enzyme.configure({ adapter: new Adapter() });
|
Enzyme.configure({ adapter: new Adapter() });
|
||||||
|
|
||||||
Object.defineProperty(document, 'readyState', {
|
Object.defineProperty(document, 'readyState', {
|
||||||
val: 'complete',
|
value: 'complete',
|
||||||
get() { return this.val; },
|
writable: true,
|
||||||
set(s) { this.val = s; },
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
var bookmarklet = "var s= document.createElement('script'); s.setAttribute('src', '"+window.location.href+"bookmarklet.js'); s.setAttribute('crossorigin', 'anonymous'); document.body.appendChild(s);"
|
var bookmarklet = "var s= document.createElement('script'); s.setAttribute('src', '"+window.location.href+"bookmarklet.js'); s.setAttribute('crossorigin', 'anonymous'); document.body.appendChild(s);"
|
||||||
bookmarklet = '(function(){'+ bookmarklet +'})();'
|
bookmarklet = '(function(){'+ bookmarklet +'})();'
|
||||||
document.querySelector('a#bookmarklet').setAttribute("href", "javascript:" + encodeURIComponent(bookmarklet));
|
document.querySelector('a#bookmarklet').setAttribute("href", "javascript:" + encodeURIComponent(bookmarklet));
|
||||||
console.log("DONE");
|
|
||||||
</script>
|
</script>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import EmbeddableWidget from './embeddable-widget';
|
import EmbeddableWidget from './embeddable-widget';
|
||||||
|
|
||||||
(function bookmarklet() {
|
export default function bookmarklet() {
|
||||||
if (window.EmbeddableWidget) {
|
if (window.EmbeddableWidget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.EmbeddableWidget = EmbeddableWidget;
|
window.EmbeddableWidget = EmbeddableWidget;
|
||||||
|
|
||||||
EmbeddableWidget.mount();
|
EmbeddableWidget.mount();
|
||||||
}());
|
}
|
||||||
|
|
||||||
|
bookmarklet();
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
import './bookmarklet';
|
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
import bookmarklet from './bookmarklet';
|
||||||
|
|
||||||
describe('bookmarklet', () => {
|
describe('bookmarklet', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
const el = document.querySelectorAll('body > div');
|
const el = document.querySelectorAll('body > div');
|
||||||
ReactDOM.unmountComponentAtNode(el[0]);
|
ReactDOM.unmountComponentAtNode(el[0]);
|
||||||
el[0].parentNode.removeChild(el[0]);
|
el[0].parentNode.removeChild(el[0]);
|
||||||
|
window.EmbeddableWidget = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('#mount document becomes ready', async () => {
|
test('#mount document becomes ready', async () => {
|
||||||
|
expect(window.EmbeddableWidget).not.toBeNull();
|
||||||
|
bookmarklet();
|
||||||
const el = document.querySelectorAll('body > div');
|
const el = document.querySelectorAll('body > div');
|
||||||
expect(el).toHaveLength(1);
|
expect(el).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,6 @@ describe('EmbeddableWidget', () => {
|
|||||||
await waitForSelection(document, 'div');
|
await waitForSelection(document, 'div');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test('#mount twice', async () => {
|
test('#mount twice', async () => {
|
||||||
EmbeddableWidget.mount();
|
EmbeddableWidget.mount();
|
||||||
expect(() => EmbeddableWidget.mount()).toThrow('already mounted');
|
expect(() => EmbeddableWidget.mount()).toThrow('already mounted');
|
||||||
|
Loading…
Reference in New Issue
Block a user