#= require "./helper" describe "The Luca Framework", -> it "should specify a version", -> expect(Luca.VERSION).toBeDefined() it "should define Luca in the global space", -> expect(Luca).toBeDefined() it "should enable bootstrap by default", -> expect(Luca.enableBootstrap).toBeTruthy() it "should have classes in the registry", -> expect( Luca.registry.classes ).toBeDefined() it "should be able to lookup classes in the registry by ctype", -> expect( Luca.registry.lookup("form_view") ).toBeTruthy() it "should allow me to add view namespaces to the registry", -> Luca.registry.addNamespace("Test.namespace") expect( Luca.registry.namespaces ).toContain("Test.namespace") it "should resolve a value.string to the object", -> window.nested = value: string: "haha" value = Luca.util.nestedValue("nested.value.string", window) expect(value).toEqual("haha") it "should create an instance of a class by ctype", -> object = ctype: "template" template: "components/form_view" component = Luca.util.lazyComponent(object) expect( _.isFunction(component.render) ).toBeTruthy() it "should find a created view in the cache", -> template = new Luca.components.Template template: "components/form_view" name: 'test_template' expect(Luca.cache("test_template")).toBeDefined() it "should detect if an object is probably a backbone view", -> obj = render: sinon.spy() el: true expect( Luca.isBackboneView(obj) ).toEqual true expect( Luca.isBackboneView({}) ).toEqual false it "should detect if an object is probably a backbone collection", -> obj = fetch: sinon.spy() reset: sinon.spy() expect( Luca.isBackboneCollection(obj) ).toEqual true expect( Luca.isBackboneCollection({}) ).toEqual false it "should detect if an object is probably a backbone model", -> obj = set: sinon.spy() get: sinon.spy() attributes: {} expect( Luca.isBackboneModel(obj) ).toEqual true expect( Luca.isBackboneModel({}) ).toEqual false describe "Luca Component Definition", -> beforeEach -> Luca.define("Luca.random.ComponentDefinition").extends("Luca.View").with property: "value" it "should create the namespace for us", -> expect( Luca.random ).toBeDefined() it "should automatically register the namespace in the registry", -> expect( Luca.registry.namespaces ).toContain 'Luca.random' it "should automatically register the component in the registry", -> expect( Luca.registry.lookup("component_definition") ).toBeDefined() it "should reference the name of the extending class", -> instance = new Luca.random.ComponentDefinition expect( instance._className ).toEqual "Luca.random.ComponentDefinition" it "should reference the extended class", -> instance = new Luca.random.ComponentDefinition expect( instance._superClass() ).toEqual Luca.View it "should reference the name of the extended class", -> instance = new Luca.random.ComponentDefinition expect( instance._superClass()._className ).toEqual 'Luca.View' it "should use the backbone.extend functionality properly", -> instance = new Luca.random.ComponentDefinition expect( instance.property ).toEqual "value" it "should alias to _.component", -> proxy = _.component('Luca.random.ComponentDefition') expect( proxy.with ).toBeDefined()