yarn-node-app-test.js 2.4 KB

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