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
3646deda
Commit
3646deda
authored
May 26, 2023
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing tests for `isSelectionBackwards`
parent
2f1fc9e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
range-util-test.js
src/annotator/test/range-util-test.js
+32
-1
No files found.
src/annotator/test/range-util-test.js
View file @
3646deda
import
*
as
rangeUtil
from
'../range-util'
;
import
*
as
rangeUtil
from
'../range-util'
;
import
{
selectedRange
}
from
'../range-util'
;
import
{
isSelectionBackwards
,
selectedRange
}
from
'../range-util'
;
function
createRange
(
node
,
start
,
end
)
{
function
createRange
(
node
,
start
,
end
)
{
const
range
=
node
.
ownerDocument
.
createRange
();
const
range
=
node
.
ownerDocument
.
createRange
();
...
@@ -210,6 +210,37 @@ describe('annotator/range-util', () => {
...
@@ -210,6 +210,37 @@ describe('annotator/range-util', () => {
});
});
});
});
describe
(
'isSelectionBackwards'
,
()
=>
{
let
container
;
beforeEach
(()
=>
{
container
=
document
.
createElement
(
'div'
);
container
.
append
(
'first'
,
'second'
);
document
.
body
.
append
(
container
);
});
afterEach
(()
=>
{
container
.
remove
();
});
[
{
nodeA
:
0
,
offsetA
:
5
,
nodeB
:
0
,
offsetB
:
2
,
backwards
:
true
},
{
nodeA
:
0
,
offsetA
:
2
,
nodeB
:
0
,
offsetB
:
5
,
backwards
:
false
},
{
nodeA
:
1
,
offsetA
:
0
,
nodeB
:
0
,
offsetB
:
0
,
backwards
:
true
},
{
nodeA
:
0
,
offsetA
:
0
,
nodeB
:
1
,
offsetB
:
0
,
backwards
:
false
},
].
forEach
(({
nodeA
,
offsetA
,
nodeB
,
offsetB
,
backwards
})
=>
{
it
(
'returns true if focus is before anchor'
,
()
=>
{
getSelection
().
setBaseAndExtent
(
container
.
childNodes
[
nodeA
],
offsetA
,
container
.
childNodes
[
nodeB
],
offsetB
);
assert
.
equal
(
isSelectionBackwards
(
getSelection
()),
backwards
);
});
});
});
describe
(
'itemsForRange'
,
()
=>
{
describe
(
'itemsForRange'
,
()
=>
{
it
(
'returns unique items for range'
,
()
=>
{
it
(
'returns unique items for range'
,
()
=>
{
const
range
=
document
.
createRange
();
const
range
=
document
.
createRange
();
...
...
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