-
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.
* Added factory package * Added factories directory to service scaffold * Added factory to generator * Added factory to generator * Added query test to scaffold * Added meta factory * Added Database cleaner * Upgraded obsolete babel versions & config * Separate app creation logic for testing * Separate app creation logic for testing * Separated test from actual code * Separated test from actual code * Scaffold test separation * Added integration test helper * Added request specs * Reverted to test in src * DRY hard coded strings * Fixed endpoint tests * Proper setup/teardown for endpoint test * Fixed content type * Run test in one thread * Properly clean up DB * Flesh out service and endpoint scaffold * Fix error with endpoint generation * Release 0.4.0: Integration and unit test with scaffold * @ctt/apig@0.4.0
- Loading branch information
Showing
25 changed files
with
553 additions
and
323 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"printWidth": 120, | ||
"proseWrap": "preserve", | ||
"singleQuote": true, | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"arrowParens": "avoid", | ||
"trailingComma": "es5" | ||
} |
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
49 changes: 49 additions & 0 deletions
49
scaffold/endpoint/persistence/mongoose/{{{scaffold_entity_capitalise}}}/queries.test.js
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,49 @@ | ||
import { factory } from 'factory-girl'; | ||
|
||
import '../../../../test/factories/{{{scaffold_factory}}}'; | ||
import queries from './queries' | ||
|
||
import { mongooseConnect, dbConfig as config } from '@ctt/crud-api'; | ||
|
||
let db, {{{scaffold_factory}}}Queries; | ||
|
||
describe('{{{scaffold_entity_capitalise}}} queries', () => { | ||
beforeAll(async () => { | ||
db = await mongooseConnect(config); | ||
{{{scaffold_factory}}}Queries = queries(db); | ||
}); | ||
|
||
afterAll(async () => { | ||
await db.disconnect(); | ||
}); | ||
|
||
describe('create', () => { | ||
it('can create a {{{scaffold_entity_capitalise}}}', async () => { | ||
const payload = await factory.attrs('{{{scaffold_entity_capitalise}}}'); | ||
|
||
const {{{scaffold_factory}}} = await {{{scaffold_factory}}}Queries.create({ payload }); | ||
|
||
expect({{{scaffold_factory}}}).toBeDefined() | ||
|
||
expect({{{scaffold_factory}}}).toHaveProperty('name') | ||
expect({{{scaffold_factory}}}).toHaveProperty('uuid') | ||
expect({{{scaffold_factory}}}['name']).toEqual(payload['name']) | ||
}); | ||
|
||
it('cannot create a {{{scaffold_entity_capitalise}}}', async () => { | ||
const payload = await factory.attrs('{{{scaffold_entity_capitalise}}}', { name: undefined }); | ||
|
||
try { | ||
await expect( | ||
await (async () => {{{scaffold_factory}}}Queries.create({ payload }))(), | ||
).resolves.toThrow(); | ||
} catch ({ errors, name, message }) { | ||
expect(name).toBe('ValidationError'); | ||
expect(message).toMatch(/`name` is required/); | ||
expect(errors).toHaveProperty('name') | ||
expect(errors['name']['path']).toBe('name'); | ||
expect(errors['name']['kind']).toBe('required'); | ||
} | ||
}) | ||
}) | ||
}); |
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
Oops, something went wrong.