Skip to content

Commit f0ea092

Browse files
committed
more tests
1 parent 0228184 commit f0ea092

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

spec/src/utils/helpers.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,28 @@ describe('ConstructorIO - Utils - Helpers', () => {
240240

241241
cleanup();
242242
});
243+
244+
it('Should return null when canonical link element does not exist', () => {
245+
const cleanup = jsdom();
246+
const canonicalEle = document.querySelector('[rel=canonical]');
247+
canonicalEle.remove();
248+
249+
expect(getCanonicalUrl()).to.be.null;
250+
cleanup();
251+
});
252+
253+
it('Should return null when href attribute is empty', () => {
254+
const cleanup = jsdom();
255+
const canonicalEle = document.querySelector('[rel=canonical]');
256+
canonicalEle.setAttribute('href', '');
257+
258+
expect(getCanonicalUrl()).to.be.null;
259+
cleanup();
260+
});
261+
262+
it('Should return null when not in a DOM context', () => {
263+
expect(getCanonicalUrl()).to.be.null;
264+
});
243265
});
244266

245267
describe('dispatchEvent', () => {

0 commit comments

Comments
 (0)