aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/button.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tests/unit/button.spec.js')
-rw-r--r--js/tests/unit/button.spec.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/js/tests/unit/button.spec.js b/js/tests/unit/button.spec.js
index 51aa73774..e7d92cb6d 100644
--- a/js/tests/unit/button.spec.js
+++ b/js/tests/unit/button.spec.js
@@ -18,12 +18,28 @@ describe('Button', () => {
clearFixture()
})
+ it('should take care of element either passed as a CSS selector or DOM element', () => {
+ fixtureEl.innerHTML = '<button data-bs-toggle="button">Placeholder</button>'
+ const buttonEl = fixtureEl.querySelector('[data-bs-toggle="button"]')
+ const buttonBySelector = new Button('[data-bs-toggle="button"]')
+ const buttonByElement = new Button(buttonEl)
+
+ expect(buttonBySelector._element).toEqual(buttonEl)
+ expect(buttonByElement._element).toEqual(buttonEl)
+ })
+
describe('VERSION', () => {
it('should return plugin version', () => {
expect(Button.VERSION).toEqual(jasmine.any(String))
})
})
+ describe('DATA_KEY', () => {
+ it('should return plugin data key', () => {
+ expect(Button.DATA_KEY).toEqual('bs.button')
+ })
+ })
+
describe('data-api', () => {
it('should toggle active class on click', () => {
fixtureEl.innerHTML = [