Skip to content

Commit 3cf14f7

Browse files
author
Arthur Ayvazov
committed
1 parent 5d8a31c commit 3cf14f7

File tree

4 files changed

+44
-14
lines changed

4 files changed

+44
-14
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"express": "^4.16.4",
7979
"extract-text-webpack-plugin": "^4.0.0-beta.0",
8080
"file-loader": "^1.1.11",
81+
"flush-promises": "^1.0.2",
8182
"friendly-errors-webpack-plugin": "^1.7.0",
8283
"html-webpack-plugin": "^3.2.0",
8384
"http-proxy-middleware": "^0.19.1",

src/components/users/Authentication.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</b-form>
4444

4545
<b-form-group>
46-
<b-form-checkbox v-model="form.fields.rememberMe.value">Запомнить меня</b-form-checkbox>
46+
<b-form-checkbox v-model="form.fields.rememberMe.value" name="rememberMe">Запомнить меня</b-form-checkbox>
4747

4848
<router-link :to="{ name: 'UserResetPassword' }" key="reset-password" class="reset-password-link">
4949
Сбросить пароль

test/unit/specs/users/Authentication.spec.js

+37-13
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,57 @@ import Authentication from '@/components/users/Authentication'
33
import BootstrapVue from 'bootstrap-vue'
44
import {$routerMocks, RouterLink, describeCheckFormFields} from '../../utils'
55
import $moment from 'moment'
6-
import $http from 'axios'
6+
// import $http from 'axios'
77

88
const localVue = createLocalVue()
99
localVue.use(BootstrapVue)
1010

11+
const request = (_url, _data) => {
12+
return new Promise((resolve, reject) => {
13+
resolve()
14+
})
15+
}
16+
17+
const mockHttp = {
18+
get: request,
19+
post: request
20+
}
21+
1122
describe('users/Authentication.vue', () => {
1223

24+
const propsData = {
25+
form: {
26+
27+
}
28+
}
29+
30+
const fields = {
31+
email: { tag: 'b-form-input-stub', value: 'test@mail.com' },
32+
password: { tag: 'b-form-input-stub', value: '12345' },
33+
rememberMe: { tag: 'b-form-checkbox-stub', value: false }
34+
}
35+
36+
Object.entries(fields).forEach((fieldName, fieldData) => {
37+
propsData.form[fieldName] = { value: fieldData.value, disabled: false }
38+
})
39+
1340
const wrapper = shallowMount(Authentication, {
14-
mocks: Object.assign({ $http, $moment }, $routerMocks),
41+
mocks: Object.assign({ $http: mockHttp, $moment }, $routerMocks),
1542
stubs: { RouterLink },
16-
propsData: {
17-
form: {
18-
19-
}
20-
},
43+
propsData,
2144
localVue
2245
})
2346

2447
it('Check component Authentication', () => {
2548
expect(wrapper.is(Authentication)).to.eql(true)
2649
})
2750

28-
describeCheckFormFields(wrapper, {
29-
fields: {
30-
email: {tag: 'b-form-input-stub'},
31-
password: {tag: 'b-form-input-stub'}
32-
}
33-
})
51+
describeCheckFormFields(wrapper, { fields })
52+
53+
/*it('Auth', async () => {
54+
55+
wrapper.find('b-button-stub[type="submit"]').trigger('click')
56+
57+
})*/
3458

3559
})

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -3744,6 +3744,11 @@ flatten@^1.0.2:
37443744
version "1.0.2"
37453745
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
37463746

3747+
flush-promises@^1.0.2:
3748+
version "1.0.2"
3749+
resolved "https://registry.yarnpkg.com/flush-promises/-/flush-promises-1.0.2.tgz#4948fd58f15281fed79cbafc86293d5bb09b2ced"
3750+
integrity sha512-G0sYfLQERwKz4+4iOZYQEZVpOt9zQrlItIxQAAYAWpfby3gbHrx0osCHz5RLl/XoXevXk0xoN4hDFky/VV9TrA==
3751+
37473752
flush-write-stream@^1.0.0:
37483753
version "1.1.1"
37493754
resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8"

0 commit comments

Comments
 (0)