@@ -2,6 +2,7 @@ import {faker} from '@faker-js/faker';
22import { TestFramework , initTestFramework } from '../test-framework' ;
33import { NonEmptyString , UUID } from 'io-ts-types' ;
44import { pipe } from 'fp-ts/lib/function' ;
5+ import * as O from 'fp-ts/Option' ;
56import { getSomeOrFail } from '../../helpers' ;
67
78import { EmailAddress } from '../../../src/types' ;
@@ -122,6 +123,11 @@ describe('get', () => {
122123 expect ( equipment . area . id ) . toStrictEqual ( createArea . id ) ;
123124 expect ( equipment . area . name ) . toStrictEqual ( createArea . name ) ;
124125 } ) ;
126+
127+ it ( 'has no training sheet' , ( ) => {
128+ const equipment = runQuery ( ) ;
129+ expect ( equipment . trainingSheetId ) . toStrictEqual ( O . none ) ;
130+ } ) ;
125131 } ) ;
126132
127133 describe ( 'when someone was marked as trainer without being an owner' , ( ) => {
@@ -701,4 +707,65 @@ describe('get', () => {
701707 expect ( trained ) . toHaveLength ( 0 ) ;
702708 } ) ;
703709 } ) ;
710+
711+ describe ( 'Equipment added to non-existant area' , ( ) => {
712+ beforeEach ( async ( ) => {
713+ await framework . commands . equipment . add ( addEquipment ) ;
714+ } ) ;
715+
716+ it ( 'returns the equipment' , ( ) => {
717+ const equipment = runQuery ( ) ;
718+ expect ( equipment . id ) . toStrictEqual ( addEquipment . id ) ;
719+ } ) ;
720+ it ( 'returns the area but with the name as unknown' , ( ) => {
721+ const equipment = runQuery ( ) ;
722+ expect ( equipment . area . id ) . toStrictEqual ( createArea . id ) ;
723+ expect ( equipment . area . name ) . toStrictEqual ( 'unknown' ) ;
724+ } ) ;
725+ } ) ;
726+
727+ describe ( 'training sheet registered' , ( ) => {
728+ beforeEach ( async ( ) => {
729+ await framework . commands . area . create ( createArea ) ;
730+ await framework . commands . equipment . add ( addEquipment ) ;
731+ await framework . commands . equipment . trainingSheet ( addTrainingSheet ) ;
732+ } ) ;
733+
734+ it ( 'returns the training sheet' , ( ) => {
735+ const equipment = runQuery ( ) ;
736+ expect ( equipment . trainingSheetId ) . toStrictEqual (
737+ O . some ( addTrainingSheet . trainingSheetId )
738+ ) ;
739+ } ) ;
740+
741+ describe ( 'training sheet remove' , ( ) => {
742+ beforeEach ( async ( ) => {
743+ await framework . commands . equipment . removeTrainingSheet ( {
744+ equipmentId : addTrainingSheet . equipmentId ,
745+ } ) ;
746+ } ) ;
747+ it ( 'has no training sheet' , ( ) => {
748+ const equipment = runQuery ( ) ;
749+ expect ( equipment . trainingSheetId ) . toStrictEqual ( O . none ) ;
750+ } ) ;
751+ } ) ;
752+
753+ describe ( 'another training sheet registered' , ( ) => {
754+ const secondAddTrainingSheet = {
755+ equipmentId : addTrainingSheet . equipmentId ,
756+ trainingSheetId : faker . string . alpha ( 8 ) ,
757+ } ;
758+ beforeEach ( async ( ) => {
759+ await framework . commands . equipment . trainingSheet (
760+ secondAddTrainingSheet
761+ ) ;
762+ } ) ;
763+ it ( 'returns the new training sheet' , ( ) => {
764+ const equipment = runQuery ( ) ;
765+ expect ( equipment . trainingSheetId ) . toStrictEqual (
766+ O . some ( secondAddTrainingSheet . trainingSheetId )
767+ ) ;
768+ } ) ;
769+ } ) ;
770+ } ) ;
704771} ) ;
0 commit comments