Skip to content

Commit

Permalink
fix: use nfinite urls
Browse files Browse the repository at this point in the history
  • Loading branch information
GuiHash committed May 26, 2021
1 parent e160f7c commit 2b43ba0
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"private": true,
"version": "0.0.0",
"license": "MIT",
"homepage": "https:/www.hubstairs.com",
"homepage": "https:/www.nfinite.app",
"repository": {
"type": "git",
"url": "https://github.com/hubstairs/display-controller.git"
},
"author": "Guillaume HERTAULT <gh@hubstairs.com>",
"author": "Guillaume HERTAULT <gh@hnfinite.com>",
"workspaces": [
"packages/*"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/display-js/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('methods', () => {
test('future calls to destroyed display should not not work', async () => {
expect.assertions(4)

const display1 = new Display(html` <iframe id="to-destroy" src="https://display.hubstairs.com/v1/1234"></iframe> `)
const display1 = new Display(html` <iframe id="to-destroy" src="https://display.nfinite.app/v1/1234"></iframe> `)

await expect(display1.destroy()).resolves.toBeUndefined()
expect(document.querySelector('#to-destroy')).toBeFalsy()
Expand Down
4 changes: 2 additions & 2 deletions packages/display-js/src/lib/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ export function createEmbed({ html }, element) {
/**
* Make an oEmbed call for the specified URL.
*
* @param {string} displayUrl The hubstairs.com url for the display.
* @param {string} displayUrl The nfinite.app url for the display.
* @param {Object} [params] Parameters to pass to oEmbed.
* @return {Promise}
*/
export function getOEmbedData({ url, displayid, displayUrl, oembedUrl, ...params } = {}) {
try {
const fullDisplayUrl = getHubstairsUrl({ url, displayid, displayUrl })

let fullOembedUrl = `${oembedUrl || 'https://api.hubstairs.com/oembed'}?url=${encodeURIComponent(fullDisplayUrl)}`
let fullOembedUrl = `${oembedUrl || 'https://my.nfinite.app/api/oembed'}?url=${encodeURIComponent(fullDisplayUrl)}`

for (const param in params) {
if (Object.prototype.hasOwnProperty.call(params, param)) {
Expand Down
26 changes: 13 additions & 13 deletions packages/display-js/src/lib/embed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const mockOEmbedResponse = {
maxheight: 1000,
title: 'My title',
maxwidth: 1250,
url: 'https://display.hubstairs.com/my-video',
url: 'https://display.nfinite.app/my-video',
html: `<iframe
width="200px"
height="160px"
src="https://display.hubstairs.com/my-video"
src="https://display.nfinite.app/my-video"
frameborder="0"
allow="autoplay; fullscreen; vr"
allowvr
Expand All @@ -32,7 +32,7 @@ webkitallowfullscreen="true"
>
</iframe>`,
provider_name: 'Hubstairs',
provider_url: 'http://www.hubstairs.com/',
provider_url: 'http://www.nfinite.app/',
}

const mockOEmbedResponseResponsive = {
Expand All @@ -43,11 +43,11 @@ const mockOEmbedResponseResponsive = {
width: 1250,
height: 1000,
title: 'My title',
url: 'https://display.hubstairs.com/v1/my-video',
url: 'https://display.nfinite.app/v1/my-video',
html: `<div style="padding:125% 0 0 0;position:relative;">
<iframe
style="position:absolute;top:0;left:0;width:100%;height:100%;"
src="https://display.hubstairs.com/v1/my-video"
src="https://display.nfinite.app/v1/my-video"
frameborder="0"
allow="autoplay; fullscreen; vr"
allowvr
Expand All @@ -58,7 +58,7 @@ webkitallowfullscreen="true"
</iframe>
</div>`,
provider_name: 'Hubstairs',
provider_url: 'http://www.hubstairs.com/',
provider_url: 'http://www.nfinite.app/',
}

beforeEach(() => {
Expand Down Expand Up @@ -94,13 +94,13 @@ describe('getOEmbedParameters', () => {

describe('getOEmbedData', () => {
test('doesn’t operate on non-Hubstairs urls', async () => {
await expect(getOEmbedData({ url: 'https://nothubstairs.com' })).rejects.toThrowError(HubstairsError)
await expect(getOEmbedData({ url: 'https://notnfinite.com' })).rejects.toThrowError(HubstairsError)
})

test('returns a json oembed response', async () => {
expect.assertions(2)
fetch.mockResponse(JSON.stringify(mockOEmbedResponse), { status: 200 })
const result = await getOEmbedData({ url: 'https://display.hubstairs.com/v1/1234' })
const result = await getOEmbedData({ url: 'https://display.nfinite.app/v1/1234' })
expect(typeof result).toBe('object')
expect(result.type).toBe('rich')
})
Expand All @@ -115,34 +115,34 @@ describe('createEmbed', () => {

test('returns the already-initialized iframe', () => {
const container = html`<div data-hubstairs-initialized></div> `
const iframe = html`<iframe src="https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec"></iframe> `
const iframe = html`<iframe src="https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec"></iframe> `
container.appendChild(iframe)
expect(createEmbed({ html: 'html' }, container)).toEqual(iframe)
})

test('creates an iframe from the oembed data', () => {
const container = html`<div></div> `
const markup = '<iframe src="https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec"></iframe>'
const markup = '<iframe src="https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec"></iframe>'

const embed = createEmbed({ html: markup }, container)
expect(container.getAttribute('data-hubstairs-initialized')).toBe('true')
expect(embed.outerHTML).toEqual(
html`<iframe src="https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec" style="display: none;"></iframe> `
html`<iframe src="https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec" style="display: none;"></iframe> `
.outerHTML,
)
})

test('returns the iframe from a responsive embed', () => {
const container = html`<div></div> `
const markup =
'<div style="position:relative;padding-bottom:42.5%;height:0"><iframe src="https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec" style="position:absolute;top:0;left:0;width:100%;height:100%" frameborder="0"></iframe></div>'
'<div style="position:relative;padding-bottom:42.5%;height:0"><iframe src="https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec" style="position:absolute;top:0;left:0;width:100%;height:100%" frameborder="0"></iframe></div>'

const embed = createEmbed({ html: markup }, container)
expect(container.getAttribute('data-hubstairs-initialized')).toBe('true')
expect(embed.outerHTML).toEqual(
html`
<iframe
src="https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec"
src="https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec"
style="position:absolute;top:0;left:0;width:100%;height:100%"
frameborder="0"
></iframe>
Expand Down
4 changes: 2 additions & 2 deletions packages/display-js/src/lib/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function getHubstairsUrl({ url, displayid, displayUrl } = {}) {
}

if (isObjectId(idOrUrl)) {
return `${displayUrl || 'https://display.hubstairs.com'}/v1/${idOrUrl}`
return `${displayUrl || 'https://display.nfinite.app'}/v1/${idOrUrl}`
}

if (isHubstairsUrl(idOrUrl)) {
Expand All @@ -101,5 +101,5 @@ export function getHubstairsUrl({ url, displayid, displayUrl } = {}) {
throw new HubstairsError(`“${displayid}” is not a valid display id.`, 'TypeError')
}

throw new HubstairsError(`“${idOrUrl}” is not a display.hubstairs.com url.`, 'TypeError')
throw new HubstairsError(`“${idOrUrl}” is not a display.nfinite.app url.`, 'TypeError')
}
14 changes: 7 additions & 7 deletions packages/display-js/src/lib/functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ describe('isHubstairsUrl', () => {
describe('getHubstairsUrl', () => {
test('returns correctly a url from the embed parameters', () => {
expect(getHubstairsUrl({ displayid: '5e417dbac5d2651adbe509ec' })).toBe(
'https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec',
'https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec',
)
expect(getHubstairsUrl({ url: 'http://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec' })).toBe(
'https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec',
expect(getHubstairsUrl({ url: 'http://display.nfinite.app/v1/5e417dbac5d2651adbe509ec' })).toBe(
'https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec',
)
expect(getHubstairsUrl({ url: 'https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec' })).toBe(
'https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec',
expect(getHubstairsUrl({ url: 'https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec' })).toBe(
'https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec',
)
})

Expand All @@ -94,13 +94,13 @@ describe('getHubstairsUrl', () => {

test('throws an error if the displayid parameter is not an integer', () => {
expect(() => {
getHubstairsUrl({ displayid: 'https://nothubstairs.com/2' })
getHubstairsUrl({ displayid: 'https://notnfinite.app/2' })
}).toThrowError(HubstairsError)
})

test('throws an error if the url parameter is not a Hubstairs url', () => {
expect(() => {
getHubstairsUrl({ url: 'https://nothubstairs.com/2' })
getHubstairsUrl({ url: 'https://notnfinite.app/aa' })
}).toThrowError(HubstairsError)
})
})
4 changes: 2 additions & 2 deletions tests_utils/browser-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import jquery from 'jquery'
const html = `<body>
<div id="test_display" data-hubstairs-displayid="5e417dbac5d2651adbe509ec"></div>
<div class="multiple">
<iframe class="two" src="https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ec"></iframe>
<iframe class="one" src="https://display.hubstairs.com/v1/5e417dbac5d2651adbe509ed"></iframe>
<iframe class="two" src="https://display.nfinite.app/v1/5e417dbac5d2651adbe509ec"></iframe>
<iframe class="one" src="https://display.nfinite.app/v1/5e417dbac5d2651adbe509ed"></iframe>
</div>
</body>`

Expand Down

0 comments on commit 2b43ba0

Please sign in to comment.