Skip to content

Commit 776bd42

Browse files
committed
fix: update cui url for newer versions
1 parent 148209b commit 776bd42

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"semantic-release": "^15.5.1"
3232
},
3333
"scripts": {
34-
"test": "jest",
34+
"test": "jest ./src",
3535
"precommit": "lint-staged",
3636
"commitmsg": "commitlint -E GIT_PARAMS",
3737
"format": "prettier-standard 'src/**/*.js'",

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const EMBED_URL = 'https://public-assets.typeform.com/confab/embed.js'

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export * from './ReactCui'
2-
export { default } from './ReactCui'
1+
export { default } from './react-cui'

src/ReactCui.js renamed to src/react-cui.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { Component, Fragment, createRef } from 'react'
22
import PropTypes from 'prop-types'
33

4-
export const EMBED_URL = 'https://labs-assets.typeform.com/cui/cui-embed.js'
4+
import { scriptTagExists } from './utils'
5+
import { EMBED_URL } from './constants'
56

67
class Cui extends Component {
78
constructor () {
@@ -49,17 +50,3 @@ Cui.propTypes = {
4950
}
5051

5152
export default Cui
52-
53-
const getScriptTags = ({ document }) => {
54-
const scriptTags = document.getElementsByTagName('head')[0].childNodes
55-
const cuiEmbedScriptTags = [].filter.call(scriptTags, script => {
56-
return script.src === EMBED_URL
57-
})
58-
return cuiEmbedScriptTags
59-
}
60-
61-
const scriptTagExists = ({ document }) => {
62-
const scriptTags = getScriptTags({ document })
63-
64-
return !!scriptTags.length
65-
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React from 'react'
22
import { shallow, mount, configure } from 'enzyme'
33
import Adapter from 'enzyme-adapter-react-16'
4-
import Cui, { EMBED_URL } from './ReactCui'
4+
import Cui from './react-cui'
5+
import { EMBED_URL } from './constants'
6+
7+
console.log(EMBED_URL)
58

69
configure({ adapter: new Adapter() })
710

src/utils.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { EMBED_URL } from './constants'
2+
3+
export const getScriptTags = ({ document }) => {
4+
const scriptTags = document.getElementsByTagName('head')[0].childNodes
5+
const cuiEmbedScriptTags = [].filter.call(scriptTags, script => {
6+
return script.src === EMBED_URL
7+
})
8+
return cuiEmbedScriptTags
9+
}
10+
11+
export const scriptTagExists = ({ document }) => {
12+
const scriptTags = getScriptTags({ document })
13+
14+
return !!scriptTags.length
15+
}

0 commit comments

Comments
 (0)