@@ -2,10 +2,8 @@ import { ResultRecord } from "./result-record";
22import { ErrorType } from "../enumerations/error-type" ;
33import { ResultErrorRecord } from "./result-error-record" ;
44import { ResultError } from "../interfaces/result-error" ;
5- import {
6- ResultRecordFactory ,
7- ResultErrorRecordFactory ,
8- } from "../tests/factories" ;
5+ import { Factory } from "rosie" ;
6+ import { FactoryType } from "../tests/factories/factory-type" ;
97
108describe ( "ResultRecord" , ( ) => {
119 // -----------------------------------------------------------------------------------------
@@ -214,33 +212,37 @@ describe("ResultRecord", () => {
214212 describe ( "doesNotHaveErrors" , ( ) => {
215213 test ( "when errors is null, returns true" , ( ) => {
216214 expect (
217- ResultRecordFactory . build ( {
215+ Factory . build < ResultRecord < any > > ( FactoryType . ResultRecord , {
218216 errors : ( null as unknown ) as any [ ] ,
219217 } ) . doesNotHaveErrors ( )
220218 ) . toBeTrue ( ) ;
221219 } ) ;
222220
223221 test ( "when errors is undefined, returns true" , ( ) => {
224222 expect (
225- ResultRecordFactory . build ( {
223+ Factory . build < ResultRecord < any > > ( FactoryType . ResultRecord , {
226224 errors : undefined ,
227225 } ) . doesNotHaveErrors ( )
228226 ) . toBeTrue ( ) ;
229227 } ) ;
230228
231229 test ( "when errors is empty array, returns true" , ( ) => {
232230 expect (
233- ResultRecordFactory . build ( { errors : [ ] } ) . doesNotHaveErrors ( )
231+ Factory . build < ResultRecord < any > > ( FactoryType . ResultRecord , {
232+ errors : [ ] ,
233+ } ) . doesNotHaveErrors ( )
234234 ) . toBeTrue ( ) ;
235235 } ) ;
236236
237237 test ( "when errors is not empty, returns false" , ( ) => {
238238 // Arrange
239- const errors = ResultErrorRecordFactory . buildList ( 1 ) ;
239+ const errors = [
240+ Factory . build < ResultErrorRecord > ( FactoryType . ResultErrorRecord ) ,
241+ ] ;
240242
241243 // Act & Assert
242244 expect (
243- ResultRecordFactory . build ( {
245+ Factory . build < ResultRecord < any > > ( FactoryType . ResultRecord , {
244246 errors : errors ,
245247 } ) . doesNotHaveErrors ( )
246248 ) . toBeFalse ( ) ;
@@ -255,9 +257,12 @@ describe("ResultRecord", () => {
255257 it ( "When no error exists for given key, then returns undefined" , ( ) => {
256258 // Arrange
257259 const errorKey = "TEST_ERROR_KEY" ;
258- const resultRecord = ResultRecordFactory . build ( {
259- errors : [ ] ,
260- } ) ;
260+ const resultRecord = Factory . build < ResultRecord < any > > (
261+ FactoryType . ResultRecord ,
262+ {
263+ errors : [ ] ,
264+ }
265+ ) ;
261266
262267 // Act
263268 const result = resultRecord . getErrorMessageFor ( errorKey ) ;
@@ -269,11 +274,19 @@ describe("ResultRecord", () => {
269274 it ( "When an error exists for the given key, then returns the error message" , ( ) => {
270275 // Arrange
271276 const errorKey = "TEST_ERROR_KEY" ;
272- const resultRecord = ResultRecordFactory . build ( {
273- errors : ResultErrorRecordFactory . buildList ( 1 , {
274- key : errorKey ,
275- } ) ,
276- } ) ;
277+ const resultRecord = Factory . build < ResultRecord < any > > (
278+ FactoryType . ResultRecord ,
279+ {
280+ errors : [
281+ Factory . build < ResultErrorRecord > (
282+ FactoryType . ResultErrorRecord ,
283+ {
284+ key : errorKey ,
285+ }
286+ ) ,
287+ ] ,
288+ }
289+ ) ;
277290
278291 // Act
279292 const result = resultRecord . getErrorMessageFor ( errorKey ) ;
0 commit comments