Skip to content

Commit

Permalink
adding tests for adding duplicate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanmtz committed Apr 5, 2024
1 parent 490f23c commit ca80ac9
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions test/task.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ const AssignMail = require('../modules/mail/assign')
const TaskMail = require('../modules/mail/task')
const taskUpdate = require('../modules/tasks/taskUpdate')

const nockAuth = () => {
nock('https://github.com')
.post('/login/oauth/access_token/', {code: 'eb518274e906c68580f7'})
.basicAuth({user: secrets.github.id, pass: secrets.github.secret})
.reply(200, {access_token: 'e72e16c7e42f292c6912e7710c838347ae178b4a'})
nock('https://api.github.com')
.persist()
.get('/repos/worknenjoy/gitpay/issues/1080')
.query({client_id: secrets.github.id, client_secret: secrets.github.secret})
.reply(200, getSingleIssue.issue)
nock('https://api.github.com')
.persist()
.get('/repos/worknenjoy/gitpay')
.query({client_id: secrets.github.id, client_secret: secrets.github.secret})
.reply(200, getSingleRepo.repo)
}

describe("tasks", () => {
// API rate limit exceeded
const createTask = (authorizationHeader, params) => {
Expand Down Expand Up @@ -110,15 +127,31 @@ describe("tasks", () => {
})

describe('Task crud', () => {
xit('should create a new task wiht projects ands organizations', (done) => {
it('should create a new task wiht projects ands organizations', (done) => {
nockAuth()

registerAndLogin(agent).then(res => {
createTask(res.headers.authorization).then(task => {
expect(task.url).to.equal('https://github.com/worknenjoy/truppie/issues/99');
createTask(res.headers.authorization, {url: 'https://github.com/worknenjoy/truppie/issues/1080'}).then(task => {
expect(task.url).to.equal('https://github.com/worknenjoy/truppie/issues/1080');
done();
}).catch(done)
}).catch(done)
})

it('should give error on update if the task already exists', (done) => {
nockAuth()

registerAndLogin(agent).then(res => {
createTask(res.headers.authorization, {url: 'https://github.com/worknenjoy/truppie/issues/1080'}).then(task => {
createTask(res.headers.authorization, {url: 'https://github.com/worknenjoy/truppie/issues/1080'}).then(task => {
expect(task.errors).exist
expect(task.errors[0].message).to.equal('url must be unique')
done();
}).catch(done)
}).catch(done)
}).catch(done)
})

xit('should try to create an invalid task', (done) => {
registerAndLogin(agent).then(res => {
agent
Expand Down

0 comments on commit ca80ac9

Please sign in to comment.