]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Alert: add a couple more tests (#35419)
authorGeoSot <geo.sotis@gmail.com>
Mon, 29 Nov 2021 12:32:11 +0000 (14:32 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Nov 2021 12:32:11 +0000 (14:32 +0200)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
js/tests/unit/alert.spec.js

index cdda997c90c80c9f9e477c335939a439fd809692..eb3d3e5fa33599440fe88df094c60ac3204eaa05 100644 (file)
@@ -179,6 +179,34 @@ describe('Alert', () => {
       expect(Alert.getInstance(alertEl)).not.toBeNull()
       expect(fixtureEl.querySelector('.alert')).not.toBeNull()
     })
+
+    it('should throw an error on undefined method', () => {
+      fixtureEl.innerHTML = '<div></div>'
+
+      const div = fixtureEl.querySelector('div')
+      const action = 'undefinedMethod'
+
+      jQueryMock.fn.alert = Alert.jQueryInterface
+      jQueryMock.elements = [div]
+
+      expect(() => {
+        jQueryMock.fn.alert.call(jQueryMock, action)
+      }).toThrowError(TypeError, `No method named "${action}"`)
+    })
+
+    it('should throw an error on protected method', () => {
+      fixtureEl.innerHTML = '<div></div>'
+
+      const div = fixtureEl.querySelector('div')
+      const action = '_getConfig'
+
+      jQueryMock.fn.alert = Alert.jQueryInterface
+      jQueryMock.elements = [div]
+
+      expect(() => {
+        jQueryMock.fn.alert.call(jQueryMock, action)
+      }).toThrowError(TypeError, `No method named "${action}"`)
+    })
   })
 
   describe('getInstance', () => {