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
a1646857
Unverified
Commit
a1646857
authored
Jun 15, 2017
by
Sean Hammond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor tests
parent
cd7d8b27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
59 deletions
+66
-59
settings-test.js
src/annotator/config/test/settings-test.js
+66
-59
No files found.
src/annotator/config/test/settings-test.js
View file @
a1646857
...
...
@@ -267,69 +267,76 @@ describe('annotator.config.settingsFrom', function() {
});
describe
(
'#hostPageSetting'
,
function
()
{
context
(
'when the client is from a browser extension'
,
function
()
{
beforeEach
(
'configure a browser extension client'
,
function
()
{
fakeIsBrowserExtension
.
returns
(
true
);
});
it
(
'always returns null'
,
function
()
{
// These settings in the host page should be ignored.
fakeConfigFuncSettingsFrom
.
returns
({
foo
:
'bar'
});
fakeSharedSettings
.
jsonConfigsFrom
.
returns
({
foo
:
'bar'
});
assert
.
isNull
(
settingsFrom
(
fakeWindow
()).
hostPageSetting
(
'foo'
));
});
});
context
(
'when the client is embedded in a web page'
,
function
()
{
beforeEach
(
'configure an embedded client'
,
function
()
{
fakeIsBrowserExtension
.
returns
(
false
);
});
it
(
'returns setting values from window.hypothesisConfig()'
,
function
()
{
fakeConfigFuncSettingsFrom
.
returns
({
foo
:
'bar'
});
assert
.
equal
(
settingsFrom
(
fakeWindow
()).
hostPageSetting
(
'foo'
),
'bar'
);
});
it
(
'returns setting values from js-hypothesis-config scripts'
,
function
()
{
fakeSharedSettings
.
jsonConfigsFrom
.
returns
({
foo
:
'bar'
});
assert
.
equal
(
settingsFrom
(
fakeWindow
()).
hostPageSetting
(
'foo'
),
'bar'
);
});
specify
(
'hypothesisConfig() overrides js-hypothesis-config'
,
function
()
{
fakeConfigFuncSettingsFrom
.
returns
({
foo
:
'fooFromHypothesisConfig'
,
});
fakeSharedSettings
.
jsonConfigsFrom
.
returns
({
foo
:
'fooFromJsHypothesisConfigScript'
,
});
assert
.
equal
(
settingsFrom
(
fakeWindow
()).
hostPageSetting
(
'foo'
),
'fooFromHypothesisConfig'
);
});
[
{
when
:
'the client is embedded in a web page'
,
specify
:
'it returns setting values from window.hypothesisConfig()'
,
isBrowserExtension
:
false
,
configFuncSettings
:
{
foo
:
'configFuncValue'
},
jsonSettings
:
{},
expected
:
'configFuncValue'
,
},
{
when
:
'the client is embedded in a web page'
,
specify
:
'it returns setting values from js-hypothesis-config objects'
,
isBrowserExtension
:
false
,
configFuncSettings
:
{},
jsonSettings
:
{
foo
:
'jsonValue'
},
expected
:
'jsonValue'
,
},
{
when
:
'the client is embedded in a web page'
,
specify
:
'hypothesisConfig() settings override js-hypothesis-config ones'
,
isBrowserExtension
:
false
,
configFuncSettings
:
{
foo
:
'configFuncValue'
},
jsonSettings
:
{
foo
:
'jsonValue'
},
expected
:
'configFuncValue'
,
},
{
when
:
'the client is embedded in a web page'
,
specify
:
'even a null from hypothesisConfig() overrides js-hypothesis-config'
,
isBrowserExtension
:
false
,
configFuncSettings
:
{
foo
:
null
},
jsonSettings
:
{
foo
:
'jsonValue'
},
expected
:
null
,
},
{
when
:
'the client is embedded in a web page'
,
specify
:
'even an undefined from hypothesisConfig() overrides js-hypothesis-config'
,
isBrowserExtension
:
false
,
configFuncSettings
:
{
foo
:
undefined
},
jsonSettings
:
{
foo
:
'jsonValue'
},
expected
:
undefined
,
},
{
when
:
'the client is embedded in a web page'
,
specify
:
"it returns undefined if the setting isn't defined anywhere"
,
isBrowserExtension
:
false
,
configFuncSettings
:
{},
jsonSettings
:
{},
expected
:
undefined
,
},
{
when
:
'the client is in a browser extension'
,
specify
:
'it always returns null'
,
isBrowserExtension
:
true
,
configFuncSettings
:
{
foo
:
'configFuncValue'
},
jsonSettings
:
{
foo
:
'jsonValue'
},
expected
:
null
,
},
].
forEach
(
function
(
test
)
{
context
(
test
.
when
,
function
()
{
specify
(
test
.
specify
,
function
()
{
fakeIsBrowserExtension
.
returns
(
test
.
isBrowserExtension
);
fakeConfigFuncSettingsFrom
.
returns
(
test
.
configFuncSettings
);
fakeSharedSettings
.
jsonConfigsFrom
.
returns
(
test
.
jsonSettings
);
var
settings
=
settingsFrom
(
fakeWindow
());
[
null
,
undefined
,
].
forEach
(
function
(
returnValue
)
{
specify
(
'even a '
+
returnValue
+
' from hypothesisConfig() overrides js-hypothesis-configs'
,
function
()
{
fakeConfigFuncSettingsFrom
.
returns
({
foo
:
returnValue
});
fakeSharedSettings
.
jsonConfigsFrom
.
returns
({
foo
:
'bar'
});
var
setting
=
settings
.
hostPageSetting
(
'foo'
);
assert
.
equal
(
setting
sFrom
(
fakeWindow
()).
hostPageSetting
(
'foo'
),
returnValue
);
assert
.
equal
(
setting
,
test
.
expected
);
});
});
it
(
"returns undefined if the setting isn't defined anywhere"
,
function
()
{
fakeConfigFuncSettingsFrom
.
returns
({});
fakeSharedSettings
.
jsonConfigsFrom
.
returns
({});
assert
.
isUndefined
(
settingsFrom
(
fakeWindow
()).
hostPageSetting
(
'foo'
));
});
});
});
});
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