2
2
/* global inject, module */
3
3
describe ( "calendar service" , function ( ) {
4
4
5
+ var $date ;
5
6
var Calendar ;
6
7
7
8
beforeEach ( module ( "materialCalendar" ) ) ;
8
9
9
- beforeEach ( inject ( function ( _Calendar_ ) {
10
+ beforeEach ( inject ( function ( _Calendar_ , _$filter_ ) {
10
11
Calendar = new _Calendar_ ( ) ;
12
+ $date = function ( year , month , day ) {
13
+ return _$filter_ ( "dateToGmt" ) ( new Date ( year , month , day , 0 , 0 ) ) ;
14
+ } ;
11
15
} ) ) ;
12
16
13
17
it ( "should have all public methods defined" , function ( ) {
@@ -28,4 +32,34 @@ describe("calendar service", function() {
28
32
expect ( angular . isArray ( Calendar . dates ) ) . toBe ( true ) ;
29
33
} ) ;
30
34
35
+ it ( "should start with the correct dates in October 2015" , function ( ) {
36
+ Calendar . init ( 2015 , 9 ) ;
37
+ expect ( angular . equals ( Calendar . start , $date ( 2015 , 9 , 1 ) ) ) . toBe ( true ) ;
38
+ expect ( angular . equals ( Calendar . weeks [ 0 ] [ 0 ] , $date ( 2015 , 8 , 27 ) ) ) . toBe ( true ) ;
39
+ } ) ;
40
+
41
+ it ( "should start with the correct dates in November 2015" , function ( ) {
42
+ Calendar . init ( 2015 , 10 ) ;
43
+ expect ( angular . equals ( Calendar . start , $date ( 2015 , 10 , 1 ) ) ) . toBe ( true ) ;
44
+ expect ( angular . equals ( Calendar . weeks [ 0 ] [ 0 ] , $date ( 2015 , 10 , 1 ) ) ) . toBe ( true ) ;
45
+ } ) ;
46
+
47
+ it ( "should start with the correct dates in July 2016" , function ( ) {
48
+ Calendar . init ( 2016 , 6 ) ;
49
+ expect ( angular . equals ( Calendar . start , $date ( 2016 , 6 , 1 ) ) ) . toBe ( true ) ;
50
+ expect ( angular . equals ( Calendar . weeks [ 0 ] [ 0 ] , $date ( 2016 , 5 , 26 ) ) ) . toBe ( true ) ;
51
+ } ) ;
52
+
53
+ it ( "should start with the correct dates in March 2017" , function ( ) {
54
+ Calendar . init ( 2017 , 2 ) ;
55
+ expect ( angular . equals ( Calendar . start , $date ( 2017 , 2 , 1 ) ) ) . toBe ( true ) ;
56
+ expect ( angular . equals ( Calendar . weeks [ 0 ] [ 0 ] , $date ( 2017 , 1 , 26 ) ) ) . toBe ( true ) ;
57
+ } ) ;
58
+
59
+ it ( "should start with the correct dates in April 2018" , function ( ) {
60
+ Calendar . init ( 2018 , 3 ) ;
61
+ expect ( angular . equals ( Calendar . start , $date ( 2018 , 3 , 1 ) ) ) . toBe ( true ) ;
62
+ expect ( angular . equals ( Calendar . weeks [ 0 ] [ 0 ] , $date ( 2018 , 3 , 1 ) ) ) . toBe ( true ) ;
63
+ } ) ;
64
+
31
65
} ) ;
0 commit comments