yarn-node-apps-test.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. import { moduleFor, test } from 'ember-qunit';
  19. moduleFor('route:yarn-node-apps', 'Unit | Route | NodeApps', {
  20. });
  21. test('Basic creation test', function(assert) {
  22. let route = this.subject();
  23. assert.ok(route);
  24. assert.ok(route.model);
  25. });
  26. test('Test getting apps on a node', function(assert) {
  27. var response = [
  28. {id:"application_1456251210105_0001", state:"FINISHED", user:"root"},
  29. {id:"application_1456251210105_0002", state:"RUNNING",user:"root",
  30. containerids:["container_e38_1456251210105_0002_01_000001",
  31. "container_e38_1456251210105_0002_01_000002"]}];
  32. var store = {
  33. query: function(type, query) {
  34. return new Ember.RSVP.Promise(function(resolve) {
  35. resolve(response.slice());
  36. });
  37. }
  38. };
  39. assert.expect(8);
  40. var route = this.subject();
  41. route.set('store', store);
  42. var model =
  43. route.model({node_id:"localhost:64318", node_addr:"localhost:8042"}).
  44. then(
  45. function(value){
  46. assert.ok(value);
  47. assert.ok(value.apps);
  48. assert.equal(value.apps.length, 2);
  49. assert.deepEqual(response[0], value.apps[0]);
  50. assert.deepEqual(response[1], value.apps[1]);
  51. assert.ok(value.nodeInfo);
  52. assert.equal(value.nodeInfo.addr, 'localhost:8042');
  53. assert.equal(value.nodeInfo.id, 'localhost:64318');
  54. }
  55. );
  56. });