diff options
| author | GeoSot <[email protected]> | 2021-11-29 14:32:11 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-29 14:32:11 +0200 |
| commit | 1692fc6b4b3ac25261fcd1353670bb58b8bc8049 (patch) | |
| tree | 488162257022812f80634d94db115e1a65fba4a2 | |
| parent | 3129ff075b36e3eb59205ee2c51682fa6a29bda4 (diff) | |
| download | bootstrap-1692fc6b4b3ac25261fcd1353670bb58b8bc8049.tar.xz bootstrap-1692fc6b4b3ac25261fcd1353670bb58b8bc8049.zip | |
Alert: add a couple more tests (#35419)
Co-authored-by: XhmikosR <[email protected]>
| -rw-r--r-- | js/tests/unit/alert.spec.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/js/tests/unit/alert.spec.js b/js/tests/unit/alert.spec.js index cdda997c9..eb3d3e5fa 100644 --- a/js/tests/unit/alert.spec.js +++ b/js/tests/unit/alert.spec.js @@ -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', () => { |
