describe "Joosy.Modules.DOM", -> beforeEach -> @$ground.seed() container = @$ground.find('#application') class @DOM extends Joosy.Module @include Joosy.Modules.DOM @mapElements posts: '.post' content: post1: '#post1' post2: '#post2' footer: '.footer' @mapEvents 'test': 'onDOMTest' $container: container describe "elements assigner", -> beforeEach -> @dom = new @DOM @dom.__assignElements() it "declares", -> class A extends @DOM @mapElements first: 'first' second: 'second' class B extends A @mapElements first: 'overrided' third: 'third' expect((new B).__elements).toEqual Object.extended posts: '.post' content: post1: '#post1' post2: '#post2' first: 'overrided' second: 'second' third: 'third' footer: '.footer' expect((new @DOM).__elements).toEqual Object.extended posts: '.post' footer: '.footer' content: post1: '#post1' post2: '#post2' describe "selector resolvance", -> it "works for plane selectors", -> expect(@dom.__extractSelector '$footer').toEqual '.footer' it "works for deep selectors", -> expect(@dom.__extractSelector '$content.$post1').toEqual '#post1' it "works for plane extended selectors", -> expect(@dom.__extractSelector '$footer tr').toEqual '.footer tr' it "works for deep extended selectors", -> expect(@dom.__extractSelector '$footer $content.$post1').toEqual '.footer #post1' it "assigns", -> target = @dom.$footer().get 0 expect(target).toBeTruthy() expect(target).toBe $('.footer', @dom.$container).get 0 expect(target).toBe @dom.$('.footer').get 0 it "assigns nesteds", -> expect(@dom.$content.$post1().get 0).toBe $('#post1').get 0 it "filters assignation", -> target = @dom.$posts('#post1').get 0 expect(target).toBeTruthy() expect(target).toBe $('#post1', @dom.$container).get 0 it "respects container boundaries", -> @$ground.prepend('