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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
3313df58
Commit
3313df58
authored
May 10, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a bunch of specs for the different components
parent
5a5b06de
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
193 additions
and
28 deletions
+193
-28
app/assets/javascripts/issue_show/components/description.vue
app/assets/javascripts/issue_show/components/description.vue
+5
-5
spec/javascripts/issue_show/components/app_spec.js
spec/javascripts/issue_show/components/app_spec.js
+23
-23
spec/javascripts/issue_show/components/description_spec.js
spec/javascripts/issue_show/components/description_spec.js
+98
-0
spec/javascripts/issue_show/components/title_spec.js
spec/javascripts/issue_show/components/title_spec.js
+67
-0
No files found.
app/assets/javascripts/issue_show/components/description.vue
View file @
3313df58
...
@@ -57,17 +57,17 @@
...
@@ -57,17 +57,17 @@
},
},
taskStatus
()
{
taskStatus
()
{
const
taskRegexMatches
=
this
.
taskStatus
.
match
(
/
(\d
+
)
of
(\d
+
)
/
);
const
taskRegexMatches
=
this
.
taskStatus
.
match
(
/
(\d
+
)
of
(\d
+
)
/
);
const
$issu
e
ableHeader
=
$
(
'
.issuable-meta
'
);
const
$issuableHeader
=
$
(
'
.issuable-meta
'
);
let
$tasks
=
$
(
'
#task_status
'
);
let
$tasks
=
$
(
'
#task_status
'
,
$issuableHeader
);
let
$tasksShort
=
$
(
'
#task_status_short
'
);
let
$tasksShort
=
$
(
'
#task_status_short
'
,
$issuableHeader
);
if
(
this
.
taskStatus
.
indexOf
(
'
0 of 0
'
)
>=
0
||
this
.
taskStatus
.
trim
()
===
''
)
{
if
(
this
.
taskStatus
.
indexOf
(
'
0 of 0
'
)
>=
0
||
this
.
taskStatus
.
trim
()
===
''
)
{
$tasks
.
remove
();
$tasks
.
remove
();
$tasksShort
.
remove
();
$tasksShort
.
remove
();
}
else
if
(
!
$tasks
.
length
&&
!
$tasksShort
.
length
)
{
}
else
if
(
!
$tasks
.
length
&&
!
$tasksShort
.
length
)
{
$tasks
=
$issu
e
ableHeader
.
append
(
'
<span id="task_status" class="hidden-xs hidden-sm"></span>
'
)
$tasks
=
$issuableHeader
.
append
(
'
<span id="task_status" class="hidden-xs hidden-sm"></span>
'
)
.
find
(
'
#task_status
'
);
.
find
(
'
#task_status
'
);
$tasksShort
=
$issu
e
ableHeader
.
append
(
'
<span id="task_status_short" class="hidden-md hidden-lg"></span>
'
)
$tasksShort
=
$issuableHeader
.
append
(
'
<span id="task_status_short" class="hidden-md hidden-lg"></span>
'
)
.
find
(
'
#task_status_short
'
);
.
find
(
'
#task_status_short
'
);
}
}
...
...
spec/javascripts/issue_show/
issue_title_description
_spec.js
→
spec/javascripts/issue_show/
components/app
_spec.js
View file @
3313df58
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
$
from
'
jquery
'
;
import
'
~/render_math
'
;
import
'
~/render_math
'
;
import
'
~/render_gfm
'
;
import
'
~/render_gfm
'
;
import
issueTitleDescription
from
'
~/issue_show/issue_title_description.vue
'
;
import
issuableApp
from
'
~/issue_show/components/app.vue
'
;
import
issueShowData
from
'
./mock_data
'
;
import
issueShowData
from
'
../mock_data
'
;
window
.
$
=
$
;
const
issueShowInterceptor
=
data
=>
(
request
,
next
)
=>
{
const
issueShowInterceptor
=
data
=>
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
data
),
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
data
),
{
...
@@ -16,42 +13,45 @@ const issueShowInterceptor = data => (request, next) => {
...
@@ -16,42 +13,45 @@ const issueShowInterceptor = data => (request, next) => {
}));
}));
};
};
describe
(
'
Issu
e Title
'
,
()
=>
{
describe
(
'
Issu
able output
'
,
()
=>
{
document
.
body
.
innerHTML
=
'
<span id="task_status"></span>
'
;
document
.
body
.
innerHTML
=
'
<span id="task_status"></span>
'
;
let
IssueTitleDescriptionComponent
;
let
vm
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
IssueTitleDescriptionComponent
=
Vue
.
extend
(
issueTitleDescription
);
const
IssuableDescriptionComponent
=
Vue
.
extend
(
issuableApp
);
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
issueShowInterceptor
);
});
it
(
'
should render a title/description and update title/description on update
'
,
(
done
)
=>
{
Vue
.
http
.
interceptors
.
push
(
issueShowInterceptor
(
issueShowData
.
initialRequest
));
Vue
.
http
.
interceptors
.
push
(
issueShowInterceptor
(
issueShowData
.
initialRequest
));
const
issueShowComponent
=
new
IssueTit
leDescriptionComponent
({
vm
=
new
Issuab
leDescriptionComponent
({
propsData
:
{
propsData
:
{
canUpdate
Issue
:
'
.css-stuff
'
,
canUpdate
:
true
,
endpoint
:
'
/gitlab-org/gitlab-shell/issues/9/rendered_title
'
,
endpoint
:
'
/gitlab-org/gitlab-shell/issues/9/rendered_title
'
,
issuableRef
:
'
#1
'
,
initialTitle
:
''
,
initialDescriptionHtml
:
''
,
initialDescriptionText
:
''
,
},
},
}).
$mount
();
}).
$mount
();
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
issueShowInterceptor
);
});
it
(
'
should render a title/description and update title/description on update
'
,
(
done
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
title
'
).
innerText
).
toContain
(
'
this is a title (#1)
'
);
expect
(
document
.
querySelector
(
'
title
'
).
innerText
).
toContain
(
'
this is a title (#1)
'
);
expect
(
issueShowComponent
.
$el
.
querySelector
(
'
.title
'
).
innerHTML
).
toContain
(
'
<p>this is a title</p>
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.title
'
).
innerHTML
).
toContain
(
'
<p>this is a title</p>
'
);
expect
(
issueShowComponent
.
$el
.
querySelector
(
'
.wiki
'
).
innerHTML
).
toContain
(
'
<p>this is a description!</p>
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.wiki
'
).
innerHTML
).
toContain
(
'
<p>this is a description!</p>
'
);
expect
(
issueShowComponent
.
$el
.
querySelector
(
'
.js-task-list-field
'
).
innerText
).
toContain
(
'
this is a description
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-task-list-field
'
).
innerText
).
toContain
(
'
this is a description
'
);
Vue
.
http
.
interceptors
.
push
(
issueShowInterceptor
(
issueShowData
.
secondRequest
));
Vue
.
http
.
interceptors
.
push
(
issueShowInterceptor
(
issueShowData
.
secondRequest
));
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
title
'
).
innerText
).
toContain
(
'
2 (#1)
'
);
expect
(
document
.
querySelector
(
'
title
'
).
innerText
).
toContain
(
'
2 (#1)
'
);
expect
(
issueShowComponent
.
$el
.
querySelector
(
'
.title
'
).
innerHTML
).
toContain
(
'
<p>2</p>
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.title
'
).
innerHTML
).
toContain
(
'
<p>2</p>
'
);
expect
(
issueShowComponent
.
$el
.
querySelector
(
'
.wiki
'
).
innerHTML
).
toContain
(
'
<p>42</p>
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.wiki
'
).
innerHTML
).
toContain
(
'
<p>42</p>
'
);
expect
(
issueShowComponent
.
$el
.
querySelector
(
'
.js-task-list-field
'
).
innerText
).
toContain
(
'
42
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-task-list-field
'
).
innerText
).
toContain
(
'
42
'
);
done
();
done
();
});
});
...
...
spec/javascripts/issue_show/components/description_spec.js
0 → 100644
View file @
3313df58
import
Vue
from
'
vue
'
;
import
descriptionComponent
from
'
~/issue_show/components/description.vue
'
;
describe
(
'
Description component
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
descriptionComponent
);
if
(
!
document
.
querySelector
(
'
.issuable-meta
'
))
{
const
metaData
=
document
.
createElement
(
'
div
'
);
metaData
.
classList
.
add
(
'
issuable-meta
'
);
document
.
body
.
appendChild
(
metaData
);
}
vm
=
new
Component
({
propsData
:
{
canUpdate
:
true
,
descriptionHtml
:
'
test
'
,
descriptionText
:
'
test
'
,
updatedAt
:
new
Date
().
toString
(),
taskStatus
:
''
,
},
}).
$mount
();
});
it
(
'
animates description changes
'
,
(
done
)
=>
{
vm
.
descriptionHtml
=
'
changed
'
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.wiki
'
).
classList
.
contains
(
'
issue-realtime-pre-pulse
'
),
).
toBeTruthy
();
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.wiki
'
).
classList
.
contains
(
'
issue-realtime-trigger-pulse
'
),
).
toBeTruthy
();
done
();
});
});
});
it
(
'
re-inits the TaskList when description changed
'
,
(
done
)
=>
{
spyOn
(
gl
,
'
TaskList
'
);
vm
.
descriptionHtml
=
'
changed
'
;
setTimeout
(()
=>
{
expect
(
gl
.
TaskList
,
).
toHaveBeenCalled
();
done
();
});
});
it
(
'
does not re-init the TaskList when canUpdate is false
'
,
(
done
)
=>
{
spyOn
(
gl
,
'
TaskList
'
);
vm
.
canUpdate
=
false
;
vm
.
descriptionHtml
=
'
changed
'
;
setTimeout
(()
=>
{
expect
(
gl
.
TaskList
,
).
not
.
toHaveBeenCalled
();
done
();
});
});
describe
(
'
taskStatus
'
,
()
=>
{
it
(
'
adds full taskStatus
'
,
(
done
)
=>
{
vm
.
taskStatus
=
'
1 of 1
'
;
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.issuable-meta #task_status
'
).
textContent
.
trim
(),
).
toBe
(
'
1 of 1
'
);
done
();
});
});
it
(
'
adds short taskStatus
'
,
(
done
)
=>
{
vm
.
taskStatus
=
'
1 of 1
'
;
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.issuable-meta #task_status_short
'
).
textContent
.
trim
(),
).
toBe
(
'
1/1 task
'
);
done
();
});
});
});
});
spec/javascripts/issue_show/components/title_spec.js
0 → 100644
View file @
3313df58
import
Vue
from
'
vue
'
;
import
titleComponent
from
'
~/issue_show/components/title.vue
'
;
describe
(
'
Title component
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
titleComponent
);
vm
=
new
Component
({
propsData
:
{
issuableRef
:
'
#1
'
,
titleHtml
:
'
Testing <img />
'
,
titleText
:
'
Testing
'
,
},
}).
$mount
();
});
it
(
'
renders title HTML
'
,
()
=>
{
expect
(
vm
.
$el
.
innerHTML
.
trim
(),
).
toBe
(
'
Testing <img>
'
);
});
it
(
'
updates page title when changing titleHtml
'
,
(
done
)
=>
{
spyOn
(
vm
,
'
setPageTitle
'
);
vm
.
titleHtml
=
'
test
'
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
setPageTitle
,
).
toHaveBeenCalled
();
done
();
});
});
it
(
'
animates title changes
'
,
(
done
)
=>
{
vm
.
titleHtml
=
'
test
'
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
classList
.
contains
(
'
issue-realtime-pre-pulse
'
),
).
toBeTruthy
();
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
classList
.
contains
(
'
issue-realtime-trigger-pulse
'
),
).
toBeTruthy
();
done
();
});
});
});
it
(
'
updates page title after changing title
'
,
(
done
)
=>
{
vm
.
titleHtml
=
'
changed
'
;
vm
.
titleText
=
'
changed
'
;
Vue
.
nextTick
(()
=>
{
expect
(
document
.
querySelector
(
'
title
'
).
textContent
.
trim
(),
).
toContain
(
'
changed
'
);
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