File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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' , ( ) => {
You can’t perform that action at this time.
0 commit comments