-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from syllogio/expose-list-propositions
feat: expose propositions field which lists all propositions
- Loading branch information
Showing
6 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
IProposition, | ||
listPropositions as _listPropositions, | ||
} from '../../lib/proposition'; | ||
import listPropositions from './listPropositions'; | ||
|
||
jest.mock('../../lib/proposition', () => ({ | ||
listPropositions: jest.fn(), | ||
})); | ||
|
||
const propositions = [ | ||
{ | ||
id: 0, | ||
supportedBy: [1, 2], | ||
supports: [], | ||
text: 'Greeks are mortal', | ||
}, | ||
{ | ||
id: 1, | ||
supportedBy: [], | ||
supports: [0], | ||
text: 'All men are mortal', | ||
}, | ||
{ | ||
id: 2, | ||
supportedBy: [], | ||
supports: [0], | ||
text: 'Greeks are men', | ||
}, | ||
]; | ||
|
||
(_listPropositions as jest.Mock<any>).mockImplementation( | ||
async (): Promise<IProposition[]> => propositions | ||
); | ||
|
||
describe('Propositions', () => { | ||
it('returns an array of propositions', async () => { | ||
await expect(listPropositions()).resolves.toEqual(propositions); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { IProposition, listPropositions } from '../../lib/proposition'; | ||
|
||
/** | ||
* GraphQL resolver for the propositions field. | ||
*/ | ||
export default async function propositions(): Promise<IProposition[]> { | ||
return listPropositions(); | ||
} |
This file contains 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
This file contains 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