diff options
| author | Johann-S <[email protected]> | 2019-10-02 11:43:54 +0200 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2019-10-03 09:55:57 +0200 |
| commit | 3d12b541c488ea09efced2fb987fcbf384c656bb (patch) | |
| tree | 1863095dd8162e25a1909cf741e32faa091c32d4 /js/src/dom/manipulator.spec.js | |
| parent | 393ddae09b0578c8d381540bdbb4e68cdec1b45b (diff) | |
| download | bootstrap-3d12b541c488ea09efced2fb987fcbf384c656bb.tar.xz bootstrap-3d12b541c488ea09efced2fb987fcbf384c656bb.zip | |
return to the original file structure to avoid breaking modularity
Diffstat (limited to 'js/src/dom/manipulator.spec.js')
| -rw-r--r-- | js/src/dom/manipulator.spec.js | 158 |
1 files changed, 0 insertions, 158 deletions
diff --git a/js/src/dom/manipulator.spec.js b/js/src/dom/manipulator.spec.js deleted file mode 100644 index e96c068d4..000000000 --- a/js/src/dom/manipulator.spec.js +++ /dev/null @@ -1,158 +0,0 @@ -import Manipulator from './manipulator' - -/** Test helpers */ -import { getFixture, clearFixture } from '../../tests/helpers/fixture' - -describe('Manipulator', () => { - let fixtureEl - - beforeAll(() => { - fixtureEl = getFixture() - }) - - afterEach(() => { - clearFixture() - }) - - describe('setDataAttribute', () => { - it('should set data attribute', () => { - fixtureEl.innerHTML = '<div></div>' - - const div = fixtureEl.querySelector('div') - - Manipulator.setDataAttribute(div, 'key', 'value') - expect(div.getAttribute('data-key')).toEqual('value') - }) - - it('should set data attribute in lower case', () => { - fixtureEl.innerHTML = '<div></div>' - - const div = fixtureEl.querySelector('div') - - Manipulator.setDataAttribute(div, 'tEsT', 'value') - expect(div.getAttribute('data-test')).toEqual('value') - }) - }) - - describe('removeDataAttribute', () => { - it('should remove data attribute', () => { - fixtureEl.innerHTML = '<div data-key="value"></div>' - - const div = fixtureEl.querySelector('div') - - Manipulator.removeDataAttribute(div, 'key') - expect(div.getAttribute('data-key')).toBeNull() - }) - - it('should remove data attribute in lower case', () => { - fixtureEl.innerHTML = '<div data-testkey="value" ></div>' - - const div = fixtureEl.querySelector('div') - - Manipulator.removeDataAttribute(div, 'tEStKeY') - expect(div.getAttribute('data-testkey')).toBeNull() - }) - }) - - describe('getDataAttributes', () => { - it('should return empty object for null', () => { - expect(Manipulator.getDataAttributes(null), {}) - expect().nothing() - }) - - it('should get all data attributes', () => { - fixtureEl.innerHTML = '<div data-test="js" data-test2="js2" ></div>' - - const div = fixtureEl.querySelector('div') - - expect(Manipulator.getDataAttributes(div)).toEqual({ - test: 'js', - test2: 'js2' - }) - }) - }) - - describe('getDataAttribute', () => { - it('should get data attribute', () => { - fixtureEl.innerHTML = '<div data-test="null" ></div>' - - const div = fixtureEl.querySelector('div') - - expect(Manipulator.getDataAttribute(div, 'test')).toBeNull() - }) - - it('should get data attribute in lower case', () => { - fixtureEl.innerHTML = '<div data-test="value" ></div>' - - const div = fixtureEl.querySelector('div') - - expect(Manipulator.getDataAttribute(div, 'tEsT')).toEqual('value') - }) - - it('should normalize data', () => { - fixtureEl.innerHTML = '<div data-test="false" ></div>' - - const div = fixtureEl.querySelector('div') - - expect(Manipulator.getDataAttribute(div, 'test')).toEqual(false) - - div.setAttribute('data-test', 'true') - expect(Manipulator.getDataAttribute(div, 'test')).toEqual(true) - - div.setAttribute('data-test', '1') - expect(Manipulator.getDataAttribute(div, 'test')).toEqual(1) - }) - }) - - describe('offset', () => { - it('should return object with two properties top and left, both numbers', () => { - fixtureEl.innerHTML = '<div></div>' - - const div = fixtureEl.querySelector('div') - const offset = Manipulator.offset(div) - - expect(offset).toBeDefined() - expect(offset.top).toEqual(jasmine.any(Number)) - expect(offset.left).toEqual(jasmine.any(Number)) - }) - }) - - describe('position', () => { - it('should return object with two properties top and left, both numbers', () => { - fixtureEl.innerHTML = '<div></div>' - - const div = fixtureEl.querySelector('div') - const position = Manipulator.position(div) - - expect(position).toBeDefined() - expect(position.top).toEqual(jasmine.any(Number)) - expect(position.left).toEqual(jasmine.any(Number)) - }) - }) - - describe('toggleClass', () => { - it('should not error out if element is null or undefined', () => { - Manipulator.toggleClass(null, 'test') - Manipulator.toggleClass(undefined, 'test') - expect().nothing() - }) - - it('should add class if it is missing', () => { - fixtureEl.innerHTML = '<div></div>' - - const div = fixtureEl.querySelector('div') - - Manipulator.toggleClass(div, 'test') - expect(div.classList.contains('test')).toEqual(true) - }) - - it('should remove class if it is set', () => { - fixtureEl.innerHTML = '<div class="test"></div>' - - const div = fixtureEl.querySelector('div') - - Manipulator.toggleClass(div, 'test') - expect(div.classList.contains('test')).toEqual(false) - }) - }) -}) |
