summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Luís <aluis@gitlab.com>2018-09-07 02:43:02 +0100
committerAndré Luís <aluis@gitlab.com>2018-09-07 02:43:02 +0100
commit1dd86a7b9c7238df8c34b4878afa88c97bcc14ec (patch)
treee7a082b375e42d786151d34f9aebb56de1285b51
parentb4d941e95fa771702f75cd1f3882401fedab3fc0 (diff)
downloadgitlab-ce-tz-mr-new-datastructure-tests-fixed.tar.gz
Proxy RAF and RIC on beforeEachstz-mr-new-datastructure-tests-fixed
-rw-r--r--spec/javascripts/diffs/store/actions_spec.js26
1 files changed, 19 insertions, 7 deletions
diff --git a/spec/javascripts/diffs/store/actions_spec.js b/spec/javascripts/diffs/store/actions_spec.js
index 8b52c9bffc7..b1d1efb69b9 100644
--- a/spec/javascripts/diffs/store/actions_spec.js
+++ b/spec/javascripts/diffs/store/actions_spec.js
@@ -14,6 +14,25 @@ import mockFile from '../mock_data/diff_file';
import mockDiscussion from '../mock_data/diff_discussions';
describe('DiffsStoreActions', () => {
+ const originalMethods = {
+ requestAnimationFrame: global.requestAnimationFrame,
+ requestIdleCallback: global.requestIdleCallback,
+ };
+
+ beforeEach(() => {
+ ['requestAnimationFrame', 'requestIdleCallback'].forEach(method => {
+ global[method] = cb => {
+ cb();
+ };
+ });
+ });
+
+ afterEach(() => {
+ ['requestAnimationFrame', 'requestIdleCallback'].forEach(method => {
+ global[method] = originalMethods[method];
+ });
+ });
+
describe('setBaseConfig', () => {
it('should set given endpoint and project path', done => {
const endpoint = '/diffs/set/endpoint';
@@ -157,11 +176,6 @@ describe('DiffsStoreActions', () => {
describe('startRenderDiffsQueue', () => {
it('should set all files to RENDER_FILE', done => {
- const actualRAF = global.requestAnimationFrame;
- global.requestAnimationFrame = cb => {
- cb();
- };
-
const state = {
diffFiles: [
{
@@ -187,8 +201,6 @@ describe('DiffsStoreActions', () => {
actions
.startRenderDiffsQueue({ state, commit: pseudoCommit })
.then(() => {
- global.requestAnimationFrame = actualRAF;
-
expect(state.diffFiles[0].renderIt).toBeTruthy();
expect(state.diffFiles[1].renderIt).toBeTruthy();