Created
March 3, 2017 14:47
-
-
Save reharik/ce99d99796905fa1c46d65f07c3959ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async activity(ctx) { | |
let activitySql = path.join(__dirname,`./../repositories/sql/activity.sql`); | |
let activity = await repository(activitySql,'get_activity_by_id', ctx.params); | |
ctx.status = 200; | |
ctx.body = { | |
status: ctx.status, | |
success: true, | |
data: activity | |
}; | |
return ctx; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Container Test', function() { | |
let mut; | |
let repositoryStub; | |
let activity; | |
let ctx1; | |
before(function () { | |
// set up mock for repo | |
repositoryStub = td.function('repository'); | |
}); | |
beforeEach(() => { | |
ctx1 = {params: {id: 1}}; | |
activity = { | |
id: 123, | |
title: "hello" | |
}; | |
}); | |
describe('#ACTIVITY CONTROLLER', () => { | |
describe('ACTIVITY', function () { | |
context('when calling activity get', function () { | |
it('should call repo', async function () { | |
let activitySql = path.join(__dirname,`./../../src/repositories/sql/activity.sql`); | |
td.when(repositoryStub(activitySql, 'get_activity_by_id', ctx1.params)).thenReturn(activity); | |
let result = await mut.activity(ctx1); | |
console.log(`==========td.explain(repositoryStub)=========`); | |
console.log(td.explain(repositoryStub)); | |
console.log(`==========END td.explain(repositoryStub)=========`); | |
td.verify(repositoryStub); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment