diff options
author | XhmikosR <xhmikosr@gmail.com> | 2021-10-14 18:16:54 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2021-12-01 15:30:49 +0300 |
commit | eb54e1a1ce9d0080a65eb7a8532503a399e506ee (patch) | |
tree | 6a7af2c0facf6211ed673d5fabbf21d7bf834d9e /js/tests/unit/button.spec.js | |
parent | 5739bf76371cb7be36598ad201b587167349681b (diff) |
tests: tweak Jasmine's matchers usage
Use:
* toBeNull
* toEqual
* toBeTrue
* toBeFalse
* toHaveSize
* toHaveClass
Diffstat (limited to 'js/tests/unit/button.spec.js')
-rw-r--r-- | js/tests/unit/button.spec.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/js/tests/unit/button.spec.js b/js/tests/unit/button.spec.js index e24ff5cb0f..30e62f0b3f 100644 --- a/js/tests/unit/button.spec.js +++ b/js/tests/unit/button.spec.js @@ -45,19 +45,19 @@ describe('Button', () => { const divTest = fixtureEl.querySelector('.test') const btnTestParent = fixtureEl.querySelector('.testParent') - expect(btn.classList.contains('active')).toEqual(false) + expect(btn).not.toHaveClass('active') btn.click() - expect(btn.classList.contains('active')).toEqual(true) + expect(btn).toHaveClass('active') btn.click() - expect(btn.classList.contains('active')).toEqual(false) + expect(btn).not.toHaveClass('active') divTest.click() - expect(btnTestParent.classList.contains('active')).toEqual(true) + expect(btnTestParent).toHaveClass('active') }) }) @@ -69,12 +69,12 @@ describe('Button', () => { const button = new Button(btnEl) expect(btnEl.getAttribute('aria-pressed')).toEqual('false') - expect(btnEl.classList.contains('active')).toEqual(false) + expect(btnEl).not.toHaveClass('active') button.toggle() expect(btnEl.getAttribute('aria-pressed')).toEqual('true') - expect(btnEl.classList.contains('active')).toEqual(true) + expect(btnEl).toHaveClass('active') }) }) @@ -121,7 +121,7 @@ describe('Button', () => { jQueryMock.fn.button.call(jQueryMock, 'toggle') expect(Button.getInstance(btnEl)).not.toBeNull() - expect(btnEl.classList.contains('active')).toEqual(true) + expect(btnEl).toHaveClass('active') }) it('should just create a button instance without calling toggle', () => { @@ -135,7 +135,7 @@ describe('Button', () => { jQueryMock.fn.button.call(jQueryMock) expect(Button.getInstance(btnEl)).not.toBeNull() - expect(btnEl.classList.contains('active')).toEqual(false) + expect(btnEl).not.toHaveClass('active') }) }) @@ -155,7 +155,7 @@ describe('Button', () => { const div = fixtureEl.querySelector('div') - expect(Button.getInstance(div)).toEqual(null) + expect(Button.getInstance(div)).toBeNull() }) }) @@ -176,7 +176,7 @@ describe('Button', () => { const div = fixtureEl.querySelector('div') - expect(Button.getInstance(div)).toEqual(null) + expect(Button.getInstance(div)).toBeNull() expect(Button.getOrCreateInstance(div)).toBeInstanceOf(Button) }) }) |