Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ee4207c

Browse files
add specs
1 parent 31bb698 commit ee4207c

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

‎package-lock.json‎

Lines changed: 21 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/App.vue‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@
1717
<th>
1818
<form class="ui form" @submit.prevent="addItem">
1919
<div class="field">
20-
<input v-model="item"
21-
type="text"
22-
class="prompt"
23-
placeholder="Add item..." value="" />
20+
<input v-model="item" type="text" class="prompt" placeholder="Add item..." value="" />
2421
</div>
25-
<button type="submit"
26-
class="ui button" :disabled="!item">Add</button>
27-
<span @click="removeAllItems"
28-
class="ui label">Remove all</span>
22+
<button type="submit" class="ui button" :disabled="!item">Add</button>
23+
<span @click="removeAllItems" class="ui label">Remove all</span>
2924
</form>
3025
</th>
3126
</tr>

‎test/specs/App.spec.js‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@ import Vue from 'vue';
22
import App from '@/App';
33

44
describe('App.vue', () => {
5-
it('should run this dummy test', () => {
6-
expect('Dummy' + ' Test!').to.equal('Dummy Test!');
5+
it('should render correct contents', () => {
6+
const Constructor = Vue.extend(App);
7+
const wm = new Constructor().$mount();
8+
expect(wm.$el.querySelector('.ui .selectable thead tr th').textContent).to.contain('Items')
9+
expect(wm.$el.querySelector('.ui .button').textContent).to.contain('Add')
10+
expect(wm.$el.querySelector('.ui .label').textContent).to.contain('Remove all')
11+
});
12+
it('should set correct default data', () => {
13+
// => функция data возвращает объект компонента App
14+
const initData = App.data();
15+
// => ожидаем, что свойство item объекта initData является пустой строкой
16+
expect(initData.item).to.equal('');
17+
// => ожидаем, что свойство items объекта initData является пустым массивом
18+
// => deep.equal - deep для сравнения объектов, ибо объекты ссылочные типы данных и простое сравнение здесь не сработает
19+
expect(initData.items).to.deep.equal([]);
720
});
821
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /