summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-02-07 12:49:27 +0000
committerPhil Hughes <me@iamphill.com>2018-02-07 12:49:27 +0000
commitf96b23207fed5022bdd2375672df47c0f8f19620 (patch)
tree3e354e6aef0d4df7c748f2d18647bd037f395a7f
parenta55cfc1e6316232e25a46416b0a60be7c1282da7 (diff)
downloadgitlab-ce-clear-job-request-timeout.tar.gz
Clear the timeout in Jobs class after each testclear-job-request-timeout
#42830
-rw-r--r--spec/javascripts/job_spec.js35
1 files changed, 20 insertions, 15 deletions
diff --git a/spec/javascripts/job_spec.js b/spec/javascripts/job_spec.js
index 03b58e9c1d0..b1a750eb1ba 100644
--- a/spec/javascripts/job_spec.js
+++ b/spec/javascripts/job_spec.js
@@ -10,6 +10,7 @@ describe('Job', () => {
const JOB_URL = `${gl.TEST_HOST}/frontend-fixtures/builds-project/-/jobs/1`;
let mock;
let response;
+ let job;
function waitForPromise() {
return new Promise(resolve => requestAnimationFrame(resolve));
@@ -33,6 +34,10 @@ describe('Job', () => {
response = {};
});
+ afterEach(() => {
+ clearTimeout(job.timeout);
+ });
+
describe('class constructor', () => {
beforeEach(() => {
jasmine.clock().install();
@@ -44,14 +49,14 @@ describe('Job', () => {
describe('setup', () => {
beforeEach(function () {
- this.job = new Job();
+ job = new Job();
});
it('copies build options', function () {
- expect(this.job.pagePath).toBe(JOB_URL);
- expect(this.job.buildStatus).toBe('success');
- expect(this.job.buildStage).toBe('test');
- expect(this.job.state).toBe('');
+ expect(job.pagePath).toBe(JOB_URL);
+ expect(job.buildStatus).toBe('success');
+ expect(job.buildStage).toBe('test');
+ expect(job.state).toBe('');
});
it('only shows the jobs matching the current stage', () => {
@@ -84,12 +89,12 @@ describe('Job', () => {
complete: false,
};
- this.job = new Job();
+ job = new Job();
waitForPromise()
.then(() => {
expect($('#build-trace .js-build-output').text()).toMatch(/Update/);
- expect(this.job.state).toBe('newstate');
+ expect(job.state).toBe('newstate');
response = {
html: '<span>More</span>',
@@ -103,7 +108,7 @@ describe('Job', () => {
.then(waitForPromise)
.then(() => {
expect($('#build-trace .js-build-output').text()).toMatch(/UpdateMore/);
- expect(this.job.state).toBe('finalstate');
+ expect(job.state).toBe('finalstate');
})
.then(done)
.catch(done.fail);
@@ -117,7 +122,7 @@ describe('Job', () => {
complete: false,
};
- this.job = new Job();
+ job = new Job();
waitForPromise()
.then(() => {
@@ -151,7 +156,7 @@ describe('Job', () => {
total: 100,
};
- this.job = new Job();
+ job = new Job();
waitForPromise()
.then(() => {
@@ -172,7 +177,7 @@ describe('Job', () => {
total: 100,
};
- this.job = new Job();
+ job = new Job();
waitForPromise()
.then(() => {
@@ -193,7 +198,7 @@ describe('Job', () => {
total: 100,
};
- this.job = new Job();
+ job = new Job();
waitForPromise()
.then(() => {
@@ -229,7 +234,7 @@ describe('Job', () => {
total: 100,
};
- this.job = new Job();
+ job = new Job();
expect(
document.querySelector('.js-raw-link').textContent.trim(),
@@ -247,7 +252,7 @@ describe('Job', () => {
total: 100,
};
- this.job = new Job();
+ job = new Job();
waitForPromise()
.then(() => {
@@ -269,7 +274,7 @@ describe('Job', () => {
total: 100,
};
- this.job = new Job();
+ job = new Job();
waitForPromise()
.then(done)