Skip to content

Commit

Permalink
fix: Actually validate result in rootCozyUrl specs
Browse files Browse the repository at this point in the history
  Our `rootCozyUrl` specs where checking whether the returned URL was
  equal to the expected one but Jest's `toEqual` matcher does not
  properly check equality between URL instances.

  We'll now validate that the returned URL's `href` property has the
  expected value.
  • Loading branch information
taratatach committed Nov 3, 2023
1 parent 9c7fe80 commit dbf6516
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/cozy-client/src/helpers/urlHelper.spec.js
Expand Up @@ -210,7 +210,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camillenimbus.mycozy.cloud'))
).resolves.toEqual(new URL('https://camillenimbus.mycozy.cloud'))
).resolves.toHaveProperty('href', 'https://camillenimbus.mycozy.cloud/')
})

it('should handle cozy-hosted https trailing slash', async () => {
Expand All @@ -222,7 +222,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camillenimbus.mycozy.cloud/'))
).resolves.toEqual(new URL('https://camillenimbus.mycozy.cloud'))
).resolves.toHaveProperty('href', 'https://camillenimbus.mycozy.cloud/')
})

it('should handle cozy-hosted https trailing path', async () => {
Expand All @@ -234,7 +234,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camillenimbus.mycozy.cloud/some-path'))
).resolves.toEqual(new URL('https://camillenimbus.mycozy.cloud'))
).resolves.toHaveProperty('href', 'https://camillenimbus.mycozy.cloud/')
})

it('should handle cozy-hosted drive web app url', async () => {
Expand All @@ -251,7 +251,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camillenimbus-drive.mycozy.cloud/#/folder'))
).resolves.toEqual(new URL('https://camillenimbus.mycozy.cloud'))
).resolves.toHaveProperty('href', 'https://camillenimbus.mycozy.cloud/')
})

it('should handle cozy-hosted photos album url', async () => {
Expand All @@ -272,7 +272,7 @@ describe('rootCozyUrl', () => {
'https://camillenimbus-photos.mycozy.cloud/#/albums/68b5cda502ae29f5fa73fd89f1be4f92'
)
)
).resolves.toEqual(new URL('https://camillenimbus.mycozy.cloud'))
).resolves.toHaveProperty('href', 'https://camillenimbus.mycozy.cloud/')
})

it('should handle cozy-hosted app name', async () => {
Expand All @@ -289,7 +289,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camillenimbus-drive.mycozy.cloud'))
).resolves.toEqual(new URL('https://camillenimbus.mycozy.cloud'))
).resolves.toHaveProperty('href', 'https://camillenimbus.mycozy.cloud/')
})

it('should handle self-hosted https', async () => {
Expand All @@ -301,7 +301,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camillenimbus.com'))
).resolves.toEqual(new URL('https://camillenimbus.com'))
).resolves.toHaveProperty('href', 'https://camillenimbus.com/')
})

it('should handle self-hosted with dash', async () => {
Expand All @@ -315,7 +315,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camille-nimbus.com'))
).resolves.toEqual(new URL('https://camille-nimbus.com'))
).resolves.toHaveProperty('href', 'https://camille-nimbus.com/')
})

it('should handle self-hosted http', async () => {
Expand All @@ -329,7 +329,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('http://camille-nimbus.com'))
).resolves.toEqual(new URL('http://camille-nimbus.com'))
).resolves.toHaveProperty('href', 'http://camille-nimbus.com/')
})

it('should handle self-hosted https with port', async () => {
Expand All @@ -343,7 +343,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camillenimbus.com:666'))
).resolves.toEqual(new URL('https://camillenimbus.com:666'))
).resolves.toHaveProperty('href', 'https://camillenimbus.com:666/')
})

it('should handle self-hosted nested drive web app url', async () => {
Expand All @@ -364,7 +364,7 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://drive.camillenimbus.com/#/folder'))
).resolves.toEqual(new URL('https://camillenimbus.com'))
).resolves.toHaveProperty('href', 'https://camillenimbus.com/')
})

it('should handle self-hosted flat drive web app url', async () => {
Expand All @@ -385,13 +385,13 @@ describe('rootCozyUrl', () => {

await expect(
rootCozyUrl(new URL('https://camille-drive.nimbus.com/#/folder'))
).resolves.toEqual(new URL('https://camille.nimbus.com'))
).resolves.toHaveProperty('href', 'https://camille.nimbus.com/')
})

it('should handle cozy.localhost', async () => {
await expect(
rootCozyUrl(new URL('http://cozy.localhost:8080'))
).resolves.toEqual(new URL('http://cozy.localhost:8080'))
).resolves.toHaveProperty('href', 'http://cozy.localhost:8080/')
})

it('expects an http or https protocol', async () => {
Expand Down

0 comments on commit dbf6516

Please sign in to comment.