1
1
import { Scroll } from '.' ;
2
2
import { ManagedDateTime } from '../utils/date-time' ;
3
+ import { CatalogItem } from '../catalog/item' ;
4
+
5
+ const CATALOG_ITEMS = [
6
+ new CatalogItem ( 1 , 'Regular Scroll' , [ ] ) ,
7
+ new CatalogItem ( 2 , 'Revered Scroll' , [ 'revered' ] ) ,
8
+ ] ;
9
+
10
+ const catalog = { get : id => CATALOG_ITEMS . find ( item => item . id === id ) } ;
3
11
4
12
describe ( 'Scroll' , ( ) => {
5
13
const lastCleaningDate = new ManagedDateTime ( '2021-01-01' ) ;
6
14
7
15
it ( 'should have an id' , ( ) => {
8
- const scroll = new Scroll ( 1 , 'Regular Scroll' , [ ] ) ;
16
+ const scroll = new Scroll ( 1 , 'Regular Scroll' , [ ] , lastCleaningDate , 1 , catalog ) ;
9
17
expect ( scroll . id ) . toBe ( 1 ) ;
10
18
} ) ;
11
19
12
20
it ( 'should have a title' , ( ) => {
13
- const scroll = new Scroll ( 1 , 'Regular Scroll' , [ ] ) ;
21
+ const scroll = new Scroll ( 1 , 'Regular Scroll' , [ ] , lastCleaningDate , 1 , catalog ) ;
14
22
expect ( scroll . title ) . toBe ( 'Regular Scroll' ) ;
15
23
} ) ;
16
24
17
25
describe ( 'hasTag' , ( ) => {
18
- const scroll = new Scroll ( 1 , 'Regular Scroll' , [ 'revered' ] ) ;
26
+ const scroll = new Scroll ( 1 , 'Regular Scroll' , [ 'revered' ] , lastCleaningDate , 2 , catalog ) ;
19
27
20
28
it ( 'should return true if the tag is present' , ( ) => {
21
29
expect ( scroll . hasTag ( 'revered' ) ) . toBe ( true ) ;
@@ -28,7 +36,7 @@ describe('Scroll', () => {
28
36
29
37
describe ( 'daysSinceLastCleaning' , ( ) => {
30
38
it ( 'should return the difference in days between last cleaned date and target date' , ( ) => {
31
- const scroll = new Scroll ( 1 , 'Revered Scroll' , [ 'revered' ] , lastCleaningDate ) ;
39
+ const scroll = new Scroll ( 2 , 'Revered Scroll' , [ 'revered' ] , lastCleaningDate , 2 , catalog ) ;
32
40
const targetDate = new ManagedDateTime ( '2021-01-02' ) ;
33
41
expect ( scroll . daysSinceLastCleaning ( targetDate ) ) . toBe ( 1 ) ;
34
42
} ) ;
@@ -38,7 +46,7 @@ describe('Scroll', () => {
38
46
describe ( 'revered scrolls' , ( ) => {
39
47
const sixHundredAndNinetyNineDaysLater = new ManagedDateTime ( '2022-11-31' ) ;
40
48
const sevenHundredAndOneDaysLater = new ManagedDateTime ( '2022-12-03' ) ;
41
- const scroll = new Scroll ( 1 , 'Revered Scroll' , [ 'revered' ] , lastCleaningDate ) ;
49
+ const scroll = new Scroll ( 2 , 'Revered Scroll' , [ 'revered' ] , lastCleaningDate , 2 , catalog ) ;
42
50
43
51
it ( 'should return true if date last cleaned is greater than 700' , ( ) => {
44
52
expect ( scroll . needsCleaning ( sevenHundredAndOneDaysLater ) ) . toBe ( true ) ;
@@ -53,7 +61,7 @@ describe('Scroll', () => {
53
61
const fourteenHundredAndNinetyNineDaysLater = new ManagedDateTime ( '2025-02-08' ) ;
54
62
const fifteenHundredAndOneDaysLater = new ManagedDateTime ( '2025-02-10' ) ;
55
63
56
- const scroll = new Scroll ( 1 , 'Regular Scroll' , [ ] , lastCleaningDate ) ;
64
+ const scroll = new Scroll ( 1 , 'Regular Scroll' , [ ] , lastCleaningDate , 1 , catalog ) ;
57
65
58
66
it ( 'should return true if date last cleaned is greater than 1500' , ( ) => {
59
67
expect ( scroll . needsCleaning ( fifteenHundredAndOneDaysLater ) ) . toBe ( true ) ;
0 commit comments