Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
f247cb7c
Commit
f247cb7c
authored
Jun 30, 2016
by
Alice Wyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for auxiliary function domainAndTitle
parent
af3cd696
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
2 deletions
+59
-2
annotation-metadata-test.js
h/static/scripts/test/annotation-metadata-test.js
+59
-2
No files found.
h/static/scripts/test/annotation-metadata-test.js
View file @
f247cb7c
...
@@ -78,8 +78,52 @@ describe('annotation-metadata', function () {
...
@@ -78,8 +78,52 @@ describe('annotation-metadata', function () {
});
});
describe
(
'.domainAndTitle'
,
function
()
{
describe
(
'.domainAndTitle'
,
function
()
{
context
(
'when the title is longer than 30 characters'
,
function
()
{
context
(
'when an annotation has a non-http(s) uri'
,
function
()
{
it
(
'truncates the title with "…"'
,
function
()
{
it
(
'returns no title link'
,
function
()
{
var
model
=
{
uri
:
'file:///example.pdf'
,
};
assert
.
equal
(
domainAndTitle
(
model
).
titleLink
,
null
);
});
});
context
(
'when an annotation has a direct link'
,
function
()
{
it
(
'returns the direct link as a title link'
,
function
()
{
var
model
=
{
links
:
{
incontext
:
'https://example.com'
,
}
};
assert
.
equal
(
domainAndTitle
(
model
).
titleLink
,
'https://example.com'
);
});
});
context
(
'when an annotation has no direct link but has a http(s) uri'
,
function
()
{
it
(
'returns the uri as title link'
,
function
()
{
var
model
=
{
uri
:
'https://example.com'
,
};
assert
.
equal
(
domainAndTitle
(
model
).
titleLink
,
'https://example.com'
);
});
});
context
(
'when the annotation title is shorter than 30 characters'
,
function
()
{
it
(
'returns the annotation title as title text'
,
function
()
{
var
model
=
{
document
:
{
title
:
[
'A Short Document Title'
],
},
};
assert
.
equal
(
domainAndTitle
(
model
).
titleText
,
'A Short Document Title'
);
});
});
context
(
'when the annotation title is longer than 30 characters'
,
function
()
{
it
(
'truncates the title text with "…"'
,
function
()
{
var
model
=
{
var
model
=
{
uri
:
'http://example.com/'
,
uri
:
'http://example.com/'
,
document
:
{
document
:
{
...
@@ -93,6 +137,19 @@ describe('annotation-metadata', function () {
...
@@ -93,6 +137,19 @@ describe('annotation-metadata', function () {
);
);
});
});
});
});
context
(
'when the document uri refers to a filename'
,
function
()
{
it
(
'returns the filename as domain text'
,
function
()
{
var
model
=
{
uri
:
'file:///path/to/example.pdf'
,
document
:
{
title
:
[
'Document Title'
],
},
};
assert
.
equal
(
domainAndTitle
(
model
).
domain
,
'example.pdf'
);
});
});
});
});
describe
(
'.location'
,
function
()
{
describe
(
'.location'
,
function
()
{
...
...
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