File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change
1
+ import type { Task } from '../../Task/Task' ;
1
2
import { Field } from './Field' ;
2
3
import { FilterOrErrorMessage } from './FilterOrErrorMessage' ;
4
+ import { FilterInstructions } from './FilterInstructions' ;
3
5
4
6
export class IdField extends Field {
7
+ private readonly filterInstructions : FilterInstructions = new FilterInstructions ( ) ;
8
+
9
+ constructor ( ) {
10
+ super ( ) ;
11
+ this . filterInstructions . add ( 'has id' , ( task : Task ) => task . id . length > 0 ) ;
12
+ }
13
+
5
14
public createFilterOrErrorMessage ( line : string ) : FilterOrErrorMessage {
6
- return FilterOrErrorMessage . fromError ( line , 'Not yet implemented' ) ;
15
+ const filterResult = this . filterInstructions . createFilterOrErrorMessage ( line ) ;
16
+ if ( filterResult . filter !== undefined ) {
17
+ return filterResult ;
18
+ }
19
+
20
+ return FilterOrErrorMessage . fromError ( line , 'Unknown instruction' ) ;
7
21
}
8
22
9
23
public fieldName ( ) : string {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ describe('id', () => {
9
9
expect ( idField . fieldName ( ) ) . toEqual ( 'id' ) ;
10
10
} ) ;
11
11
12
- it . failing ( 'by id presence' , ( ) => {
12
+ it ( 'by id presence' , ( ) => {
13
13
// Arrange
14
14
const filter = new IdField ( ) . createFilterOrErrorMessage ( 'has id' ) ;
15
15
You can’t perform that action at this time.
0 commit comments