yarn-node-app-test.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 { moduleForModel, test } from 'ember-qunit';
  19. import Ember from 'ember';
  20. moduleForModel('yarn-node-app', 'Unit | Model | NodeApp', {
  21. // Specify the other units that are required for this test.
  22. needs: []
  23. });
  24. test('Basic creation test', function(assert) {
  25. let model = this.subject();
  26. assert.ok(model);
  27. assert.ok(model._notifyProperties);
  28. assert.ok(model.didLoad);
  29. assert.ok(model.appId);
  30. assert.ok(model.state);
  31. assert.ok(model.user);
  32. assert.ok(model.containers);
  33. });
  34. test('test fields', function(assert) {
  35. let model = this.subject();
  36. assert.expect(9);
  37. Ember.run(function () {
  38. model.set("appId", "application_1456251210105_0002");
  39. model.set("id", "application_1456251210105_0002");
  40. model.set("state", "RUNNING");
  41. model.set("user", "hadoop");
  42. model.set("containers", ["container_e38_1456251210105_0002_01_000001",
  43. "container_e38_1456251210105_0002_01_000002"]);
  44. assert.equal(model.get("appId"), "application_1456251210105_0002");
  45. assert.equal(model.get("state"), "RUNNING");
  46. assert.equal(model.get("user"), "hadoop");
  47. assert.deepEqual(model.get("containers"),
  48. ["container_e38_1456251210105_0002_01_000001",
  49. "container_e38_1456251210105_0002_01_000002"]);
  50. assert.equal(model.get("appStateStyle"), "label label-primary");
  51. assert.equal(model.get("isDummyApp"), false);
  52. model.set("id", "dummy");
  53. assert.equal(model.get("isDummyApp"), true);
  54. model.set("state", "FINISHED");
  55. assert.equal(model.get("appStateStyle"), "label label-success");
  56. model.set("state", "NEW");
  57. assert.equal(model.get("appStateStyle"), "label label-default");
  58. });
  59. });