@@ -3,7 +3,7 @@ import $ from "jquery";
3
3
import Base from "./base" ;
4
4
import _ from "underscore" ;
5
5
6
- describe ( "pat-base: The Base class for patterns" , function ( ) {
6
+ describe ( "pat-base: The Base class for patterns" , function ( ) {
7
7
var patterns = registry . patterns ;
8
8
9
9
beforeEach ( function ( ) {
@@ -14,21 +14,21 @@ describe("pat-base: The Base class for patterns", function() {
14
14
registry . patterns = patterns ;
15
15
} ) ;
16
16
17
- it ( "can be extended and used in similar way as classes" , function ( ) {
17
+ it ( "can be extended and used in similar way as classes" , function ( ) {
18
18
var Tmp = Base . extend ( {
19
19
name : "example" ,
20
20
trigger : "pat-example" ,
21
21
some : "thing" ,
22
- init : function ( ) {
22
+ init : function ( ) {
23
23
expect ( this . $el . hasClass ( "pat-example" ) ) . toEqual ( true ) ;
24
24
expect ( _ . includes ( _ . keys ( this . options ) , "option" ) ) . toBeTruthy ( ) ;
25
25
this . extra ( ) ;
26
26
} ,
27
- extra : function ( ) {
27
+ extra : function ( ) {
28
28
expect ( this . some ) . toEqual ( "thing" ) ;
29
- }
29
+ } ,
30
30
} ) ;
31
- var tmp = new Tmp ( $ ( " <div class=\ "pat-example\ "/>" ) , { option : "value" } ) ;
31
+ var tmp = new Tmp ( $ ( ' <div class="pat-example"/>' ) , { option : "value" } ) ;
32
32
expect ( tmp instanceof Tmp ) . toBeTruthy ( ) ;
33
33
} ) ;
34
34
@@ -54,11 +54,11 @@ describe("pat-base: The Base class for patterns", function() {
54
54
expect ( tmp instanceof Tmp ) . toBeTruthy ( ) ;
55
55
} ) ;
56
56
57
- it ( "will automatically register a pattern in the registry when extended" , function ( ) {
57
+ it ( "will automatically register a pattern in the registry when extended" , function ( ) {
58
58
spyOn ( registry , "register" ) . and . callThrough ( ) ;
59
59
var NewPattern = Base . extend ( {
60
60
name : "example" ,
61
- trigger : ".pat-example"
61
+ trigger : ".pat-example" ,
62
62
} ) ;
63
63
expect ( NewPattern . prototype . trigger ) . toEqual ( ".pat-example" ) ;
64
64
expect ( NewPattern . prototype . name ) . toEqual ( "example" ) ;
@@ -67,86 +67,87 @@ describe("pat-base: The Base class for patterns", function() {
67
67
expect ( _ . includes ( _ . keys ( registry . patterns ) , "example" ) ) . toBeTruthy ( ) ;
68
68
} ) ;
69
69
70
- it ( " will not automatically register a pattern without a \ "name\ " attribute" , function ( ) {
70
+ it ( ' will not automatically register a pattern without a "name" attribute' , function ( ) {
71
71
spyOn ( registry , "register" ) . and . callThrough ( ) ;
72
- var NewPattern = Base . extend ( { trigger : ".pat-example" } ) ;
72
+ var NewPattern = Base . extend ( { trigger : ".pat-example" } ) ;
73
73
expect ( NewPattern . prototype . trigger ) . toEqual ( ".pat-example" ) ;
74
74
expect ( registry . register ) . not . toHaveBeenCalled ( ) ;
75
75
} ) ;
76
76
77
- it ( " will not automatically register a pattern without a \ "trigger\ " attribute" , function ( ) {
77
+ it ( ' will not automatically register a pattern without a "trigger" attribute' , function ( ) {
78
78
spyOn ( registry , "register" ) . and . callThrough ( ) ;
79
- var NewPattern = Base . extend ( { name : "example" } ) ;
79
+ var NewPattern = Base . extend ( { name : "example" } ) ;
80
80
expect ( registry . register ) . not . toHaveBeenCalled ( ) ;
81
81
expect ( NewPattern . prototype . name ) . toEqual ( "example" ) ;
82
82
} ) ;
83
83
84
- it ( "will instantiate new instances of a pattern when the DOM is scanned" , function ( ) {
84
+ it ( "will instantiate new instances of a pattern when the DOM is scanned" , function ( ) {
85
85
var NewPattern = Base . extend ( {
86
86
name : "example" ,
87
87
trigger : ".pat-example" ,
88
- init : function ( ) {
88
+ init : function ( ) {
89
89
expect ( this . $el . attr ( "class" ) ) . toEqual ( "pat-example" ) ;
90
- }
90
+ } ,
91
91
} ) ;
92
92
spyOn ( NewPattern , "init" ) . and . callThrough ( ) ;
93
- registry . scan ( $ ( " <div class=\ "pat-example\ "/>" ) ) ;
93
+ registry . scan ( $ ( ' <div class="pat-example"/>' ) ) ;
94
94
expect ( NewPattern . init ) . toHaveBeenCalled ( ) ;
95
95
} ) ;
96
96
97
- it ( "requires that patterns that extend it provide an object of properties" , function ( ) {
98
- expect ( Base . extend )
99
- . toThrowError (
100
- "Pattern configuration properties required when calling Base.extend"
101
- ) ;
97
+ it ( "requires that patterns that extend it provide an object of properties" , function ( ) {
98
+ expect ( Base . extend ) . toThrowError (
99
+ "Pattern configuration properties required when calling Base.extend"
100
+ ) ;
102
101
} ) ;
103
102
104
- it ( "can be extended multiple times" , function ( ) {
103
+ it ( "can be extended multiple times" , function ( ) {
105
104
var Tmp1 = Base . extend ( {
106
105
name : "thing" ,
107
106
trigger : "pat-thing" ,
108
107
something : "else" ,
109
- init : function ( ) {
108
+ init : function ( ) {
110
109
expect ( this . some ) . toEqual ( "thing3" ) ;
111
110
expect ( this . something ) . toEqual ( "else" ) ;
112
- }
111
+ } ,
113
112
} ) ;
114
113
var Tmp2 = Tmp1 . extend ( {
115
114
name : "thing" ,
116
115
trigger : "pat-thing" ,
117
116
some : "thing2" ,
118
- init : function ( ) {
117
+ init : function ( ) {
119
118
expect ( this . some ) . toEqual ( "thing3" ) ;
120
119
expect ( this . something ) . toEqual ( "else" ) ;
121
- this . constructor . __super__ . constructor . __super__ . init . call ( this ) ;
122
- }
120
+ this . constructor . __super__ . constructor . __super__ . init . call (
121
+ this
122
+ ) ;
123
+ } ,
123
124
} ) ;
124
125
var Tmp3 = Tmp2 . extend ( {
125
126
name : "thing" ,
126
127
trigger : "pat-thing" ,
127
128
some : "thing3" ,
128
- init : function ( ) {
129
+ init : function ( ) {
129
130
expect ( this . some ) . toEqual ( "thing3" ) ;
130
131
expect ( this . something ) . toEqual ( "else" ) ;
131
132
this . constructor . __super__ . init . call ( this ) ;
132
- }
133
+ } ,
133
134
} ) ;
134
- new Tmp3 ( $ ( "<div>" ) , { option : "value" } ) ;
135
+ new Tmp3 ( $ ( "<div>" ) , { option : "value" } ) ;
135
136
} ) ;
136
137
137
- it ( "has on/emit helpers to prefix events" , function ( ) {
138
+ it ( "has on/emit helpers to prefix events" , function ( ) {
138
139
var Tmp = Base . extend ( {
139
140
name : "tmp" ,
140
141
trigger : ".pat-tmp" ,
141
- init : function ( ) {
142
- this . on ( "something" , function ( e , arg1 ) {
142
+ init : function ( ) {
143
+ this . on ( "something" , function ( e , arg1 ) {
143
144
expect ( arg1 ) . toEqual ( "yaay!" ) ;
144
145
} ) ;
145
146
this . emit ( "somethingelse" , [ "yaay!" ] ) ;
146
- }
147
+ } ,
147
148
} ) ;
148
149
new Tmp (
149
- $ ( "<div/>" ) . on ( "somethingelse.tmp.patterns" , function ( e , arg1 ) {
150
+ $ ( "<div/>" ) . on ( "somethingelse.tmp.patterns" , function ( e , arg1 ) {
150
151
$ ( this ) . trigger ( "something.tmp.patterns" , [ arg1 ] ) ;
151
152
} )
152
153
) ;
0 commit comments