96ef6a282f6dde24621452faf0db755ca6a34749
[ccsdk/features.git] /
1 describe("app.ux.singleton", function(){
2
3 var Singleton = window.app.ux.Singleton;
4
5         describe("creating a singleton", function() {
6                 var X = Singleton.extend({
7                         foo: function() {
8                                 return "bar";
9                         }
10                 });
11
12                 var Y = Singleton.extend({
13                         bar: function() {
14                                 return "baz";
15                         }
16                 });
17
18                 it("should have properties like a normal class", function() {
19                         var a = X.instance();
20
21                         expect( a instanceof X ).toBe( true );
22                         expect( a.foo() ).toBe( "bar" );
23                 });
24
25                 it("should return single instance each time instance() is called", function() {
26                         var a = X.instance();
27                         var b = X.instance();
28
29                         expect( a ).toBe( b );
30                 });
31
32                 it("should not share instances with different singletons", function() {
33                         var a = X.instance();
34                         var c = Y.instance();
35
36                         expect( a ).not.toBe( c );
37                 });
38
39         });
40
41 });