4 |
5 | Mocha Tests
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
20 |
21 |
22 |
23 |
26 |
--------------------------------------------------------------------------------
/tests/getters.js:
--------------------------------------------------------------------------------
1 | import $ from '../domProxy.js';
2 |
3 | describe('getters primitives', function () {
4 | it('getter className on singel element', function () {
5 | document.body.className = 'test4';
6 | chai.expect($('body').className).to.equal('test4');
7 | });
8 | it('getter on multiple elements (first should be returned)', function () {
9 | $('head').className = 'test_33';
10 | chai.expect($('head, body').className).to.equal('test_33');
11 | });
12 | it('getter on void list should be null?', function () {
13 | chai.expect($('.doesNotExists').className).to.equal(null);
14 | });
15 | it('ensureId()', function () {
16 | const genId = $('body').ensureId();
17 | chai.expect(genId).to.not.equal('');
18 | chai.expect(document.body.id).to.equal(genId);
19 | });
20 | });
21 |
22 | describe('getters methods', function () {
23 | });
24 |
25 |
26 | describe('getters extended', function () {
27 | });
28 |
--------------------------------------------------------------------------------
/tests/setters.js:
--------------------------------------------------------------------------------
1 | import $ from '../domProxy.js';
2 |
3 | describe('setter', function () {
4 | const body = document.body;
5 | it('setting className on singel element', function () {
6 | $(body).className = 'test';
7 | chai.expect(body.className).to.equal('test');
8 | });
9 | it('setting className on multiple elements', function () {
10 | $('body, head').className = 'test2';
11 | chai.expect(document.body.className).to.equal('test2');
12 | chai.expect(document.head.className).to.equal('test2');
13 | });
14 | it('setting multiple events', function () {
15 | const listener = function(){ };
16 | $('body, head').onmouseover = listener;
17 | chai.expect(document.body.onmouseover).to.equal(listener);
18 | chai.expect(document.head.onmouseover).to.equal(listener);
19 | });
20 | it('setting on void list', function () {
21 | $('.doesnotExists').classList = 'xyz';
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Tobias Buschor
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/tests.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | domProxy tests
7 |
8 |
domProxy tests
9 |
10 |
11 |
12 | test
13 | span
14 | a
15 | b
16 | c
17 | d
18 | other span
19 |
20 |
21 | test
22 | span
23 | a
24 | span
25 |
26 |
27 |
28 |
29 |
66 |
--------------------------------------------------------------------------------
/tests/constructor.js:
--------------------------------------------------------------------------------
1 | import $ from '../domProxy.js';
2 |
3 | describe('constructor single element', function () {
4 | const body = document.body;
5 | it('first entry should be the element', function () {
6 | const domProxy = $(body);
7 | chai.expect(domProxy.values().next().value).to.equal(body);
8 | });
9 | it('size should be 1', function () {
10 | const body = document.body;
11 | const domProxy = $(body);
12 | chai.expect(domProxy.size).to.equal(1);
13 | });
14 | });
15 |
16 | describe('constructor html content', function () {
17 | it('first element should be "TR"', function () {
18 | const domProxy = $('
');
19 | chai.expect(domProxy.values().next().value.tagName).to.equal('TR');
20 | });
21 | it('first element should be "svg', function () {
22 | const domProxy = $('