Added runner update tests
This commit is contained in:
		@@ -35,4 +35,111 @@ describe('Update runner name after adding', () => {
 | 
			
		||||
        updated_runner = res3.data
 | 
			
		||||
        expect(updated_runner).toEqual(runnercopy);
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
// ---------------
 | 
			
		||||
describe('Update runner group after adding', () => {
 | 
			
		||||
    let added_org_id;
 | 
			
		||||
    let added_org_2;
 | 
			
		||||
    let added_runner;
 | 
			
		||||
    let updated_runner;
 | 
			
		||||
    it('creating a new org with just a name should return 200', async () => {
 | 
			
		||||
        const res1 = await axios.post(base + '/api/organisations', {
 | 
			
		||||
            "name": "test123"
 | 
			
		||||
        });
 | 
			
		||||
        let added_org = res1.data
 | 
			
		||||
        added_org_id = added_org.id;
 | 
			
		||||
        expect(res1.status).toEqual(200);
 | 
			
		||||
        expect(res1.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
    it('creating a new runner with only needed params should return 200', async () => {
 | 
			
		||||
        const res2 = await axios.post(base + '/api/runners', {
 | 
			
		||||
            "firstname": "first",
 | 
			
		||||
            "lastname": "last",
 | 
			
		||||
            "group": added_org_id
 | 
			
		||||
        }, { validateStatus: undefined });
 | 
			
		||||
        added_runner = res2.data;
 | 
			
		||||
        expect(res2.status).toEqual(200);
 | 
			
		||||
        expect(res2.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
    it('creating a new org with just a name should return 200', async () => {
 | 
			
		||||
        const res3 = await axios.post(base + '/api/organisations', {
 | 
			
		||||
            "name": "test123"
 | 
			
		||||
        });
 | 
			
		||||
        added_org_2 = res3.data
 | 
			
		||||
        delete added_org_2.address;
 | 
			
		||||
        delete added_org_2.contact;
 | 
			
		||||
        delete added_org_2.teams;
 | 
			
		||||
        expect(res3.status).toEqual(200);
 | 
			
		||||
        expect(res3.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
    it('valid update should return 200', async () => {
 | 
			
		||||
        added_runner.group = added_org_2;
 | 
			
		||||
        const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, { validateStatus: undefined });
 | 
			
		||||
        expect(res3.status).toEqual(200);
 | 
			
		||||
        expect(res3.headers['content-type']).toContain("application/json")
 | 
			
		||||
        updated_runner = res3.data
 | 
			
		||||
        expect(updated_runner).toEqual(added_runner);
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
// ---------------
 | 
			
		||||
describe('Update runner id after adding(should fail)', () => {
 | 
			
		||||
    let added_org_id;
 | 
			
		||||
    let added_runner;
 | 
			
		||||
    let added_runner_id;
 | 
			
		||||
    it('creating a new org with just a name should return 200', async () => {
 | 
			
		||||
        const res1 = await axios.post(base + '/api/organisations', {
 | 
			
		||||
            "name": "test123"
 | 
			
		||||
        });
 | 
			
		||||
        let added_org = res1.data
 | 
			
		||||
        added_org_id = added_org.id;
 | 
			
		||||
        expect(res1.status).toEqual(200);
 | 
			
		||||
        expect(res1.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
    it('creating a new runner with only needed params should return 200', async () => {
 | 
			
		||||
        const res2 = await axios.post(base + '/api/runners', {
 | 
			
		||||
            "firstname": "first",
 | 
			
		||||
            "lastname": "last",
 | 
			
		||||
            "group": added_org_id
 | 
			
		||||
        }, { validateStatus: undefined });
 | 
			
		||||
        added_runner = res2.data;
 | 
			
		||||
        added_runner_id = added_runner.id;
 | 
			
		||||
        expect(res2.status).toEqual(200);
 | 
			
		||||
        expect(res2.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
    it('invalid update should return 406', async () => {
 | 
			
		||||
        added_runner.id++;
 | 
			
		||||
        const res3 = await axios.put(base + '/api/runners/' + added_runner_id, added_runner, { validateStatus: undefined });
 | 
			
		||||
        expect(res3.status).toEqual(406);
 | 
			
		||||
        expect(res3.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
// ---------------
 | 
			
		||||
describe('Update runner group with invalid group after adding', () => {
 | 
			
		||||
    let added_org;
 | 
			
		||||
    let added_runner;
 | 
			
		||||
    it('creating a new org with just a name should return 200', async () => {
 | 
			
		||||
        const res1 = await axios.post(base + '/api/organisations', {
 | 
			
		||||
            "name": "test123"
 | 
			
		||||
        });
 | 
			
		||||
        added_org = res1.data
 | 
			
		||||
        expect(res1.status).toEqual(200);
 | 
			
		||||
        expect(res1.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
    it('creating a new runner with only needed params should return 200', async () => {
 | 
			
		||||
        const res2 = await axios.post(base + '/api/runners', {
 | 
			
		||||
            "firstname": "first",
 | 
			
		||||
            "lastname": "last",
 | 
			
		||||
            "group": added_org.id
 | 
			
		||||
        }, { validateStatus: undefined });
 | 
			
		||||
        added_runner = res2.data;
 | 
			
		||||
        expect(res2.status).toEqual(200);
 | 
			
		||||
        expect(res2.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
    it('invalid update should return 404', async () => {
 | 
			
		||||
        added_org.id++;
 | 
			
		||||
        added_runner.group = added_org;
 | 
			
		||||
        const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, { validateStatus: undefined });
 | 
			
		||||
        expect(res3.status).toEqual(404);
 | 
			
		||||
        expect(res3.headers['content-type']).toContain("application/json")
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user