mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-15 12:06:42 +02:00
Add further container tests
This commit is contained in:
parent
843d1f66bb
commit
d5167b0106
|
@ -31,7 +31,6 @@ describe('Container', () => {
|
|||
expect(instance.classNames).to.eql(DEFAULT_CLASSNAMES);
|
||||
});
|
||||
|
||||
|
||||
describe('addEventListeners', () => {
|
||||
let addEventListenerStub;
|
||||
|
||||
|
@ -86,23 +85,7 @@ describe('Container', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('focus', () => {
|
||||
let focusStub;
|
||||
|
||||
beforeEach(() => {
|
||||
focusStub = sinon.stub(instance.element, 'focus');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
focusStub.restore();
|
||||
});
|
||||
|
||||
it('focuses element if isFocussed flag is set to false', () => {
|
||||
instance.isFocussed = false;
|
||||
instance.focus();
|
||||
expect(focusStub.callCount).to.equal(1);
|
||||
});
|
||||
});
|
||||
// describe('shouldFlip', () => { });
|
||||
|
||||
describe('setActiveDescendant', () => {
|
||||
it('sets element\'s aria-activedescendant attribute with passed descendant ID', () => {
|
||||
|
@ -122,4 +105,78 @@ describe('Container', () => {
|
|||
expect(instance.element.getAttribute('aria-activedescendant')).to.equal(null);
|
||||
});
|
||||
});
|
||||
|
||||
// describe('open', () => { });
|
||||
// describe('close', () => { });
|
||||
|
||||
describe('focus', () => {
|
||||
let focusStub;
|
||||
|
||||
beforeEach(() => {
|
||||
focusStub = sinon.stub(instance.element, 'focus');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
focusStub.restore();
|
||||
});
|
||||
|
||||
it('focuses element if isFocussed flag is set to false', () => {
|
||||
instance.isFocussed = false;
|
||||
instance.focus();
|
||||
expect(focusStub.callCount).to.equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
// describe('addFocusState', () => { });
|
||||
// describe('removeFocusState', () => { });
|
||||
// describe('enable', () => {});
|
||||
// describe('disable', () => {});
|
||||
|
||||
describe('addLoadingState', () => {
|
||||
beforeEach(() => {
|
||||
instance.removeLoadingState();
|
||||
});
|
||||
|
||||
it('adds loading state class', () => {
|
||||
expect(instance.element.classList.contains(DEFAULT_CLASSNAMES.loadingState)).to.equal(false);
|
||||
instance.addLoadingState();
|
||||
expect(instance.element.classList.contains(DEFAULT_CLASSNAMES.loadingState)).to.equal(true);
|
||||
});
|
||||
|
||||
it('sets aria-busy attribute to true', () => {
|
||||
expect(instance.element.getAttribute('aria-busy')).to.equal(null);
|
||||
instance.addLoadingState();
|
||||
expect(instance.element.getAttribute('aria-busy')).to.equal('true');
|
||||
});
|
||||
|
||||
it('sets isLoading flag to false', () => {
|
||||
expect(instance.isLoading).to.equal(false);
|
||||
instance.addLoadingState();
|
||||
expect(instance.isLoading).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeLoadingState', () => {
|
||||
beforeEach(() => {
|
||||
instance.addLoadingState();
|
||||
});
|
||||
|
||||
it('removes loading state class', () => {
|
||||
expect(instance.element.classList.contains(DEFAULT_CLASSNAMES.loadingState)).to.equal(true);
|
||||
instance.removeLoadingState();
|
||||
expect(instance.element.classList.contains(DEFAULT_CLASSNAMES.loadingState)).to.equal(false);
|
||||
});
|
||||
|
||||
it('removes aria-busy attribute', () => {
|
||||
expect(instance.element.getAttribute('aria-busy')).to.equal('true');
|
||||
instance.removeLoadingState();
|
||||
expect(instance.element.getAttribute('aria-busy')).to.equal(null);
|
||||
});
|
||||
|
||||
it('sets isLoading flag to true', () => {
|
||||
expect(instance.isLoading).to.equal(true);
|
||||
instance.removeLoadingState();
|
||||
expect(instance.isLoading).to.equal(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue