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
a22f54ba
Commit
a22f54ba
authored
Mar 11, 2020
by
Nicolò Maria Mezzopera
Committed by
Kushal Pandya
Mar 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate sketch index_spec to jest
- migrate index_spec - rename balsamiq_viewer to browser_spec
parent
559622c5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
0 deletions
+94
-0
spec/frontend/blob/sketch/index_spec.js
spec/frontend/blob/sketch/index_spec.js
+92
-0
spec/javascripts/blob/balsamiq/balsamiq_viewer_browser_spec.js
...javascripts/blob/balsamiq/balsamiq_viewer_browser_spec.js
+2
-0
No files found.
spec/
javascripts
/blob/sketch/index_spec.js
→
spec/
frontend
/blob/sketch/index_spec.js
View file @
a22f54ba
/* eslint-disable no-new, promise/catch-or-return */
import
JSZip
from
'
jszip
'
;
import
JSZip
from
'
jszip
'
;
import
SketchLoader
from
'
~/blob/sketch
'
;
import
SketchLoader
from
'
~/blob/sketch
'
;
describe
(
'
Sketch viewer
'
,
()
=>
{
jest
.
mock
(
'
jszip
'
);
const
generateZipFileArrayBuffer
=
(
zipFile
,
resolve
,
done
)
=>
{
zipFile
.
generateAsync
({
type
:
'
arrayBuffer
'
}).
then
(
content
=>
{
resolve
(
content
);
setTimeout
(()
=>
{
done
();
},
100
);
});
};
describe
(
'
Sketch viewer
'
,
()
=>
{
preloadFixtures
(
'
static/sketch_viewer.html
'
);
preloadFixtures
(
'
static/sketch_viewer.html
'
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
'
static/sketch_viewer.html
'
);
loadFixtures
(
'
static/sketch_viewer.html
'
);
window
.
URL
=
{
createObjectURL
:
jest
.
fn
(()
=>
'
http://foo/bar
'
),
};
});
afterEach
(()
=>
{
window
.
URL
=
{};
});
});
describe
(
'
with error message
'
,
()
=>
{
describe
(
'
with error message
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
spyOn
(
SketchLoader
.
prototype
,
'
getZipFile
'
).
and
.
callFake
(
jest
.
spyOn
(
SketchLoader
.
prototype
,
'
getZipFile
'
).
mockImplementation
(
()
=>
()
=>
new
Promise
((
resolve
,
reject
)
=>
{
new
Promise
((
resolve
,
reject
)
=>
{
reject
();
reject
();
setTimeout
(()
=>
{
done
();
done
();
});
}),
}),
);
);
new
SketchLoader
(
document
.
getElementById
(
'
js-sketch-viewer
'
));
return
new
SketchLoader
(
document
.
getElementById
(
'
js-sketch-viewer
'
));
});
});
it
(
'
renders error message
'
,
()
=>
{
it
(
'
renders error message
'
,
()
=>
{
...
@@ -43,39 +38,39 @@ describe('Sketch viewer', () => {
...
@@ -43,39 +38,39 @@ describe('Sketch viewer', () => {
);
);
});
});
it
(
'
removes
render
the loading icon
'
,
()
=>
{
it
(
'
removes the loading icon
'
,
()
=>
{
expect
(
document
.
querySelector
(
'
.js-loading-icon
'
)).
toBeNull
();
expect
(
document
.
querySelector
(
'
.js-loading-icon
'
)).
toBeNull
();
});
});
});
});
describe
(
'
success
'
,
()
=>
{
describe
(
'
success
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
spyOn
(
SketchLoader
.
prototype
,
'
getZipFile
'
).
and
.
callFake
(
const
loadAsyncMock
=
{
()
=>
files
:
{
new
Promise
(
resolve
=>
{
'
previews/preview.png
'
:
{
const
zipFile
=
new
JSZip
();
async
:
jest
.
fn
(),
zipFile
.
folder
(
'
previews
'
)
.
file
(
'
preview.png
'
,
'
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAA1JREFUeNoBAgD9/wAAAAIAAVMrnDAAAAAASUVORK5CYII=
'
,
{
base64
:
true
,
},
},
);
},
};
generateZipFileArrayBuffer
(
zipFile
,
resolve
,
done
);
loadAsyncMock
.
files
[
'
previews/preview.png
'
].
async
.
mockImplementation
(
()
=>
new
Promise
(
resolve
=>
{
resolve
(
'
foo
'
);
done
();
}),
}),
);
);
new
SketchLoader
(
document
.
getElementById
(
'
js-sketch-viewer
'
));
jest
.
spyOn
(
SketchLoader
.
prototype
,
'
getZipFile
'
).
mockResolvedValue
();
jest
.
spyOn
(
JSZip
,
'
loadAsync
'
).
mockResolvedValue
(
loadAsyncMock
);
return
new
SketchLoader
(
document
.
getElementById
(
'
js-sketch-viewer
'
));
});
});
it
(
'
does not render error message
'
,
()
=>
{
it
(
'
does not render error message
'
,
()
=>
{
expect
(
document
.
querySelector
(
'
#js-sketch-viewer p
'
)).
toBeNull
();
expect
(
document
.
querySelector
(
'
#js-sketch-viewer p
'
)).
toBeNull
();
});
});
it
(
'
removes
render
the loading icon
'
,
()
=>
{
it
(
'
removes the loading icon
'
,
()
=>
{
expect
(
document
.
querySelector
(
'
.js-loading-icon
'
)).
toBeNull
();
expect
(
document
.
querySelector
(
'
.js-loading-icon
'
)).
toBeNull
();
});
});
...
@@ -94,27 +89,4 @@ describe('Sketch viewer', () => {
...
@@ -94,27 +89,4 @@ describe('Sketch viewer', () => {
expect
(
link
.
target
).
toBe
(
'
_blank
'
);
expect
(
link
.
target
).
toBe
(
'
_blank
'
);
});
});
});
});
describe
(
'
incorrect file
'
,
()
=>
{
beforeEach
(
done
=>
{
spyOn
(
SketchLoader
.
prototype
,
'
getZipFile
'
).
and
.
callFake
(
()
=>
new
Promise
(
resolve
=>
{
const
zipFile
=
new
JSZip
();
generateZipFileArrayBuffer
(
zipFile
,
resolve
,
done
);
}),
);
new
SketchLoader
(
document
.
getElementById
(
'
js-sketch-viewer
'
));
});
it
(
'
renders error message
'
,
()
=>
{
expect
(
document
.
querySelector
(
'
#js-sketch-viewer p
'
)).
not
.
toBeNull
();
expect
(
document
.
querySelector
(
'
#js-sketch-viewer p
'
).
textContent
.
trim
()).
toContain
(
'
Cannot show preview.
'
,
);
});
});
});
});
spec/javascripts/blob/balsamiq/balsamiq_viewer_
integration
_spec.js
→
spec/javascripts/blob/balsamiq/balsamiq_viewer_
browser
_spec.js
View file @
a22f54ba
// this file can't be migrated to jest because it relies on the browser to perform integration tests:
// see: https://gitlab.com/gitlab-org/gitlab/-/issues/194207#note_301878738
import
{
FIXTURES_PATH
}
from
'
spec/test_constants
'
;
import
{
FIXTURES_PATH
}
from
'
spec/test_constants
'
;
import
BalsamiqViewer
from
'
~/blob/balsamiq/balsamiq_viewer
'
;
import
BalsamiqViewer
from
'
~/blob/balsamiq/balsamiq_viewer
'
;
...
...
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