Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f80d2ab3
Commit
f80d2ab3
authored
May 15, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for description field
[ci skip]
parent
96a46521
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
222 additions
and
0 deletions
+222
-0
spec/javascripts/issue_show/components/fields/description_spec.js
...ascripts/issue_show/components/fields/description_spec.js
+34
-0
spec/javascripts/vue_shared/components/markdown/field_spec.js
.../javascripts/vue_shared/components/markdown/field_spec.js
+121
-0
spec/javascripts/vue_shared/components/markdown/header_spec.js
...javascripts/vue_shared/components/markdown/header_spec.js
+67
-0
No files found.
spec/javascripts/issue_show/components/fields/description_spec.js
0 → 100644
View file @
f80d2ab3
import
Vue
from
'
vue
'
;
import
Store
from
'
~/issue_show/stores
'
;
import
descriptionField
from
'
~/issue_show/components/fields/description.vue
'
;
describe
(
'
Description field component
'
,
()
=>
{
let
vm
;
let
store
;
beforeEach
((
done
)
=>
{
const
Component
=
Vue
.
extend
(
descriptionField
);
store
=
new
Store
({
titleHtml
:
''
,
descriptionHtml
:
''
,
issuableRef
:
''
,
});
store
.
formState
.
description
=
'
test
'
;
vm
=
new
Component
({
propsData
:
{
markdownPreviewUrl
:
'
/
'
,
markdownDocs
:
'
/
'
,
store
,
},
}).
$mount
();
Vue
.
nextTick
(
done
);
});
it
(
'
renders markdown field with description
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.md-area textarea
'
).
value
,
).
toBe
(
'
test
'
);
});
});
spec/javascripts/vue_shared/components/markdown/field_spec.js
0 → 100644
View file @
f80d2ab3
import
Vue
from
'
vue
'
;
import
fieldComponent
from
'
~/vue_shared/components/markdown/field.vue
'
;
describe
(
'
Markdown field component
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
new
Vue
({
render
(
createElement
)
{
return
createElement
(
fieldComponent
,
{
props
:
{
markdownPreviewUrl
:
'
/preview
'
,
markdownDocs
:
'
/docs
'
,
},
},
[
createElement
(
'
textarea
'
,
{
slot
:
'
textarea
'
,
}),
],
);
},
});
});
it
(
'
creates a new instance of GL form
'
,
(
done
)
=>
{
spyOn
(
gl
,
'
GLForm
'
);
vm
.
$mount
();
Vue
.
nextTick
(()
=>
{
expect
(
gl
.
GLForm
,
).
toHaveBeenCalled
();
done
();
});
});
describe
(
'
mounted
'
,
()
=>
{
beforeEach
((
done
)
=>
{
vm
.
$mount
();
Vue
.
nextTick
(
done
);
});
it
(
'
renders textarea inside backdrop
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.zen-backdrop textarea
'
),
).
not
.
toBeNull
();
});
describe
(
'
markdown preview
'
,
()
=>
{
let
previewLink
;
beforeEach
(()
=>
{
spyOn
(
Vue
.
http
,
'
post
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
resolve
({
json
()
{
return
{
body
:
'
<p>markdown preview</p>
'
,
};
},
});
}));
previewLink
=
vm
.
$el
.
querySelector
(
'
.nav-links li:nth-child(2) a
'
);
});
it
(
'
sets preview link as active
'
,
(
done
)
=>
{
previewLink
.
click
();
Vue
.
nextTick
(()
=>
{
expect
(
previewLink
.
parentNode
.
classList
.
contains
(
'
active
'
),
).
toBeTruthy
();
done
();
});
});
it
(
'
shows preview loading text
'
,
(
done
)
=>
{
previewLink
.
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.md-preview
'
).
textContent
.
trim
(),
).
toContain
(
'
Loading...
'
);
done
();
});
});
it
(
'
renders markdown preview
'
,
(
done
)
=>
{
previewLink
.
click
();
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.md-preview
'
).
innerHTML
,
).
toContain
(
'
<p>markdown preview</p>
'
);
done
();
});
});
it
(
'
renders GFM with jQuery
'
,
(
done
)
=>
{
spyOn
(
$
.
fn
,
'
renderGFM
'
);
previewLink
.
click
();
setTimeout
(()
=>
{
expect
(
$
.
fn
.
renderGFM
,
).
toHaveBeenCalled
();
done
();
});
});
});
});
});
spec/javascripts/vue_shared/components/markdown/header_spec.js
0 → 100644
View file @
f80d2ab3
import
Vue
from
'
vue
'
;
import
headerComponent
from
'
~/vue_shared/components/markdown/header.vue
'
;
describe
(
'
Markdown field header component
'
,
()
=>
{
let
vm
;
beforeEach
((
done
)
=>
{
const
Component
=
Vue
.
extend
(
headerComponent
);
vm
=
new
Component
({
propsData
:
{
previewMarkdown
:
false
,
},
}).
$mount
();
Vue
.
nextTick
(
done
);
});
it
(
'
renders markdown buttons
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-md
'
).
length
,
).
toBe
(
7
);
});
it
(
'
renders `write` link as active when previewMarkdown is false
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
li:nth-child(1)
'
).
classList
.
contains
(
'
active
'
),
).
toBeTruthy
();
});
it
(
'
renders `preview` link as active when previewMarkdown is true
'
,
(
done
)
=>
{
vm
.
previewMarkdown
=
true
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
li:nth-child(2)
'
).
classList
.
contains
(
'
active
'
),
).
toBeTruthy
();
done
();
});
});
it
(
'
emits toggle markdown event when clicking preview
'
,
()
=>
{
spyOn
(
vm
,
'
$emit
'
);
vm
.
$el
.
querySelector
(
'
li:nth-child(2) a
'
).
click
();
expect
(
vm
.
$emit
,
).
toHaveBeenCalledWith
(
'
toggle-markdown
'
);
});
it
(
'
blurs preview link after click
'
,
(
done
)
=>
{
const
link
=
vm
.
$el
.
querySelector
(
'
li:nth-child(2) a
'
);
spyOn
(
HTMLElement
.
prototype
,
'
blur
'
);
link
.
click
();
setTimeout
(()
=>
{
expect
(
link
.
blur
,
).
toHaveBeenCalled
();
done
();
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment