forked from vuejs/vue-hackernews-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem-spec.js
51 lines (44 loc) · 1.16 KB
/
item-spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import VueRouter from 'vue-router'
import router from '../../src/router'
import Item from '../../src/components/Item.vue'
import { timeAgo, host } from '../../src/util/filters'
import { createRouter } from '../../src/router'
import VueRouter from 'vue-router'
import mountVue from 'cypress-vue-unit-test'
/* eslint-env mocha */
/* global cy, Cypress */
describe('Item', () => {
const template = `<news-item :item="item"></news-item>`
const components = {
'news-item': Item
}
const data = {
item: {
title: 'Vue unit testing with Cypress',
score: 101,
url: 'https://www.cypress.io',
id: 'a0x',
by: 'bahmutov',
time: Cypress.moment('Jan 22 2018').unix(),
descendants: 42
}
}
const extensions = {
plugins: [VueRouter],
filters: { timeAgo, host }
}
const options = {
extensions
}
const router = createRouter()
beforeEach(() => {
cy.viewport(400, 200)
})
beforeEach(mountVue({ template, router, components, data }, options))
it('loads news item', () => {
cy.contains('.score', 101)
})
it('has link to comments', () => {
cy.contains('.comments-link > a', '42 comments')
})
})