This repository was archived by the owner on Jun 22, 2021. It is now read-only.
File tree 4 files changed +64
-1
lines changed
4 files changed +64
-1
lines changed Original file line number Diff line number Diff line change
1
+ import 'mocha' ; // tslint:disable-line:no-import-side-effect
2
+ import * as assert from 'power-assert' ;
3
+ import Facade from '../../Facade' ;
4
+ import Filter from '../../types/Filter' ;
5
+ import { TestEntity , TestId } from '../testEntity' ;
6
+
7
+ export default ( facade : Facade < TestId , TestEntity > ) => {
8
+ describe ( 'countEntities' , ( ) => {
9
+ it ( 'should return 0 when there are no entities' , async ( ) => {
10
+ const filter : Filter < TestEntity > = { } ;
11
+ const { count } = await facade . countEntities ( { filter } ) ;
12
+ assert . equal ( count , 0 ) ;
13
+ } ) ;
14
+ } ) ;
15
+ } ;
Original file line number Diff line number Diff line change
1
+ import 'mocha' ; // tslint:disable-line:no-import-side-effect
2
+ import * as assert from 'power-assert' ;
3
+ import Facade from '../../Facade' ;
4
+ import { Result as GetEntitiesResult } from '../../signatures/GetEntities' ;
5
+ import Filter from '../../types/Filter' ;
6
+ import Pagination from '../../types/Pagination' ;
7
+ import Sort from '../../types/Sort' ;
8
+ import { TestEntity , TestId } from '../testEntity' ;
9
+
10
+ export default ( facade : Facade < TestId , TestEntity > ) => {
11
+ describe ( 'getEntities' , ( ) => {
12
+ it ( 'should return no entities when there are no entities' , async ( ) => {
13
+ const filter : Filter < TestEntity > = { } ;
14
+ const sort : Sort < TestEntity > = { } ;
15
+ const pagination : Pagination = { cursor : undefined , forward : true , limit : 1 } ;
16
+ const actualResult = await facade . getEntities ( { filter, sort, pagination } ) ;
17
+ const expectedResult : GetEntitiesResult < TestEntity > = {
18
+ entities : [ ] ,
19
+ nextCursor : undefined ,
20
+ previousCursor : undefined ,
21
+ } ;
22
+ assert . deepEqual ( actualResult , expectedResult ) ;
23
+ } ) ;
24
+ } ) ;
25
+ } ;
Original file line number Diff line number Diff line change
1
+ import * as assertRejects from 'assert-rejects' ;
2
+ import 'mocha' ; // tslint:disable-line:no-import-side-effect
3
+ import MissingEntityError from '../../errors/MissingEntityError' ;
4
+ import Facade from '../../Facade' ;
5
+ import Filter from '../../types/Filter' ;
6
+ import { TestEntity , testEntity , testId , TestId } from '../testEntity' ;
7
+
8
+ export default ( facade : Facade < TestId , TestEntity > ) => {
9
+ describe ( 'removeEntities' , ( ) => {
10
+ it ( 'should not error when there are no entities' , async ( ) => {
11
+ const filter : Filter < TestEntity > = { } ;
12
+ await facade . removeEntities ( { filter } ) ;
13
+ } ) ;
14
+
15
+ it ( 'should remove all entities when there are entities' , async ( ) => {
16
+ const filter : Filter < TestEntity > = { } ;
17
+ await facade . createEntity ( { entity : testEntity } ) ;
18
+ await facade . removeEntities ( { filter } ) ;
19
+ const promise = facade . getEntity ( { id : testId } ) ;
20
+ await assertRejects ( promise , MissingEntityError ) ;
21
+ } ) ;
22
+ } ) ;
23
+ } ;
Original file line number Diff line number Diff line change 1
1
type Sort < Entity > = {
2
- readonly [ P in keyof Entity ] : boolean | undefined ;
2
+ readonly [ P in keyof Entity ] ? : boolean ;
3
3
} ;
4
4
5
5
export default Sort ;
You can’t perform that action at this time.
0 commit comments