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
af3307f7
Commit
af3307f7
authored
Mar 11, 2019
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add getJSONFixture() helper to Jest
parent
aeffdd2a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
3 deletions
+27
-3
jest.config.js
jest.config.js
+0
-1
spec/frontend/gfm_auto_complete_spec.js
spec/frontend/gfm_auto_complete_spec.js
+3
-2
spec/frontend/helpers/fixtures.js
spec/frontend/helpers/fixtures.js
+24
-0
No files found.
jest.config.js
View file @
af3307f7
...
...
@@ -18,7 +18,6 @@ module.exports = {
moduleNameMapper
:
{
'
^~(.*)$
'
:
'
<rootDir>/app/assets/javascripts$1
'
,
'
^ee(.*)$
'
:
'
<rootDir>/ee/app/assets/javascripts$1
'
,
'
^fixtures(.*)$
'
:
'
<rootDir>/spec/javascripts/fixtures$1
'
,
'
^helpers(.*)$
'
:
'
<rootDir>/spec/frontend/helpers$1
'
,
'
^vendor(.*)$
'
:
'
<rootDir>/vendor/assets/javascripts$1
'
,
'
\\
.(jpg|jpeg|png|svg)$
'
:
'
<rootDir>/spec/frontend/__mocks__/file_mock.js
'
,
...
...
spec/frontend/gfm_auto_complete_spec.js
View file @
af3307f7
...
...
@@ -8,11 +8,12 @@ import 'vendor/jquery.atwho';
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
setTestTimeout
}
from
'
helpers/timeout
'
;
import
labelsFixture
from
'
fixtures/autocomplete_sources/labels.json
'
;
// eslint-disable-line import/no-unresolved
import
{
getJSONFixture
}
from
'
helpers/fixtures
'
;
setTestTimeout
(
500
);
const
labelsFixture
=
getJSONFixture
(
'
autocomplete_sources/labels.json
'
);
describe
(
'
GfmAutoComplete
'
,
()
=>
{
const
gfmAutoCompleteCallbacks
=
GfmAutoComplete
.
prototype
.
getDefaultCallbacks
.
call
({
fetchData
:
()
=>
{},
...
...
spec/frontend/helpers/fixtures.js
0 → 100644
View file @
af3307f7
/* eslint-disable import/prefer-default-export, global-require, import/no-dynamic-require */
import
fs
from
'
fs
'
;
import
path
from
'
path
'
;
// jest-util is part of Jest
// eslint-disable-next-line import/no-extraneous-dependencies
import
{
ErrorWithStack
}
from
'
jest-util
'
;
const
fixturesBasePath
=
path
.
join
(
process
.
cwd
(),
'
spec
'
,
'
javascripts
'
,
'
fixtures
'
);
export
function
getJSONFixture
(
relativePath
,
ee
=
false
)
{
const
absolutePath
=
path
.
join
(
fixturesBasePath
,
ee
?
'
ee
'
:
''
,
relativePath
);
if
(
!
fs
.
existsSync
(
absolutePath
))
{
throw
new
ErrorWithStack
(
`Fixture file
${
relativePath
}
does not exist.
Did you run bin/rake karma:fixtures?`
,
getJSONFixture
,
);
}
return
require
(
absolutePath
);
}
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