     expect(p.provider).toBe(r.provider)
     expect(p.archive).toBe(r.archive)
     expect(p.nodes).toBe(r.nodes)
+
+  it 'should provide all packages if no node is selected', () ->
+    scope.allPackages = allPackages1
+    scope.updatePackageSelection()
+    expect( scope.packages ).toBe( scope.allPackages )
+
+  it 'should provide only the packages assigned to a selected node', () ->
+    scope.allPackages = allPackages1
+    scope.node['n'] = {}
+    scope.node['n'].packages = [ { 'id': allPackages1[0].versions[0].id } ]
+    scope.nodeSelected['n'] = true
+    scope.updatePackageSelection()
+    expect( scope.packages.length ).toBe( 1 )
+    expect( scope.packages[0].name ).toBe( allPackages1[0].name )

  afterEach () ->
    @httpBackend.verifyNoOutstandingExpectation()
    @httpBackend.verifyNoOutstandingRequest()

  it 'should have no default host configured', () ->
    expect(scope.ponyExpressHost).toBe(undefined)

    expect(n.packages[0].summary).toBe( 'query and manipulate user account information' )

  it 'should be a able to fetch /packages', () ->
    ps = allPackages1
    paginateResponse @httpBackend, '/v1/packages', ps, () -> scope.fetchPackages()

    expect(scope.packages.length).toBe(ps.length)
    # test both packages
    for idx in [0,1]
      res_p = scope.packages[idx]
      expect(@typeOf(res_p)).toBe('object')
      expect(res_p.name).toBe(ps[idx].name)
      expect(res_p.versions.length).toBe(ps[idx].versions.length)

      # every package we load creates an entry in the package map
      for v in res_p.versions
        p = scope.package[v.id]
        expect(@typeOf(p)).toBe('object')
        expect(p.name).toBe(ps[idx].name)
        expect(p.version).toBe(v.version)
        expect(p.versions).toBe(undefined)

