Skip to content

Commit cec2910

Browse files
committed
test: fix vitests
1 parent 8efc9a2 commit cec2910

23 files changed

Lines changed: 36036 additions & 1501 deletions

components/appbar/appbar.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Component } from '../atomic/component.mjs';
2+
3+
// AppBar is the old *Navbar*
4+
5+
/*
6+
<nav class="nav navbar">
7+
<div class="nav-wrapper">
8+
<a href="#" class="brand-logo">Logo</a>
9+
<ul id="nav-mobile" class="right hide-on-med-and-down">
10+
<li><a href="sass.html">Sass</a></li>
11+
<li><a href="badges.html">Components</a></li>
12+
<li><a href="collapsible.html">JavaScript</a></li>
13+
</ul>
14+
</div>
15+
</nav>
16+
*/
17+
18+
class AppBar extends Component {
19+
constructor(options) {
20+
super(options);
21+
this.setTagName('nav').addClassname('nav navbar');
22+
}
23+
24+
toHTML() {
25+
const html = `<div class="nav-wrapper">
26+
<a href="#" class="brand-logo">Logo</a>
27+
<ul id="nav-mobile" class="right hide-on-med-and-down">
28+
<li><a href="sass.html">Sass</a></li>
29+
<li><a href="badges.html">Components</a></li>
30+
<li><a href="collapsible.html">JavaScript</a></li>
31+
</ul>
32+
</div>`;
33+
this.setChildren(html);
34+
return super.toHTML();
35+
}
36+
}
37+
38+
export { AppBar };

components/appbar/appbar.test.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, expect, test } from 'vitest';
2+
import { AppBar } from './appbar.mjs';
3+
4+
describe('appBar', () => {
5+
test('create html', () => {
6+
const appBar = new AppBar();
7+
expect(appBar.toHTML()).toContain('<nav');
8+
});
9+
});

components/chip/chip.test.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
import { describe, expect, test } from 'vitest';
12
import { Chip } from './chip.mjs';
23

3-
const chip = new Chip().setText('John Doe');
4-
console.log(chip.toHTML());
4+
describe('chip', () => {
5+
test('create html', () => {
6+
const chip = new Chip().setText('John Doe');
7+
//console.log(list.toHTML());
8+
expect(chip.toHTML()).toContain('John');
9+
});
10+
});

components/datepicker/datepicker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Utils } from '../../src/utils';
22
import { BaseOptions, Component, I18nOptions, InitElements, MElement } from '../../src/component';
3-
import { FormSelect } from '../text-field/select';
3+
import { FormSelect } from '../textfield/select';
44
import { DockedDisplayPlugin } from '../../src/dockedDisplayPlugin';
55
import { ModalDisplayPlugin } from '../../src/modalDisplayPlugin';
66

components/list/list.test.mjs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import { describe, expect, test } from 'vitest';
12
import { List, ListItem } from './list.mjs';
23

3-
const data = ['HP Pavilion dv6-6013cl', 'Dell XPS 15 (Sandy Bridge)', 'Lenovo ThinkPad X220'];
4+
describe('list', () => {
5+
const testData = ['HP Pavilion dv6-6013cl', 'Dell XPS 15 (Sandy Bridge)', 'Lenovo ThinkPad X220'];
46

5-
const list = new List();
6-
data.map((raw) => {
7-
const item = new ListItem().setText(raw);
8-
list.addItem(item);
7+
test('create html', () => {
8+
const list = new List();
9+
testData.map((raw) => {
10+
const item = new ListItem().setText(raw);
11+
list.addItem(item);
12+
});
13+
//console.log(list.toHTML());
14+
expect(list.toHTML()).toContain('Pavilion');
15+
});
916
});
10-
11-
console.log(list.toHTML());
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
import { describe, expect, test } from 'vitest';
12
import { LoadingIndicator } from './loading.mjs';
23

3-
const loading = new LoadingIndicator();
4-
console.log(loading.toHTML());
4+
describe('loading', () => {
5+
test('create html', () => {
6+
const loading = new LoadingIndicator();
7+
//console.log(list.toHTML());
8+
expect(loading.toHTML()).toContain('circle');
9+
});
10+
});

components/textfield/text-field.mjs

Lines changed: 0 additions & 37 deletions
This file was deleted.

components/textfield/text-field.test.mjs

Lines changed: 0 additions & 4 deletions
This file was deleted.

components/textfield/textfield.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component } from '../component.mjs';
1+
import { Component } from '../atomic/component.mjs';
22

33
class TextField extends Component {
44
#labelText;
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { TextField } from './text-field.mjs';
1+
import { describe, expect, test } from 'vitest';
2+
import { TextField } from './textfield.mjs';
23

3-
const textfield = new TextField().setLabel('Name');
4-
console.log(textfield.toHTML());
4+
describe('textfields', () => {
5+
test('create html', () => {
6+
const textfield = new TextField().setLabel('Name');
7+
//console.log(list.toHTML());
8+
expect(textfield.toHTML()).toContain('<input');
9+
});
10+
});

0 commit comments

Comments
 (0)