var Vue = require("vuejs");
var ApplicationListModel = require("user/ApplicationListModel");
var ApplicationLabel = require("user/vue-components/ApplicationLabel");
var $ = require("jquery");
require("filters");

QUnit.module("user.app_label");
QUnit.test("application name", function(assert) {
  var done = assert.async();

  var model = new ApplicationListModel();
  var appLabel = new ApplicationLabel({
    data: function() { return { model: model }; }
  }).$mount();

  model.update().done(function() {
    Vue.nextTick(function() {
      assert.equal(
        appLabel.$el.querySelector('li > a > span').innerHTML,
        model.appList[0].appData.image.ui_name
      );

      // Simulate changing currentApp
      model.selectedIndex = 1;

      Vue.nextTick(function() {
        assert.equal(
          appLabel.$el.querySelector('li > a > span').innerHTML,
          model.appList[1].appData.image.ui_name
        );

        done();
      });
    })
  });
});

QUnit.test("rendering stop button", function (assert) {
  var done = assert.async();

  var model = new ApplicationListModel();
  var appLabel = new ApplicationLabel({
    data: function() { return { model: model }; }
  }).$mount();

  model.update().done(function() {
    // Simulate application stopped
    model.appList[0].status = 'STOPPED';

    Vue.nextTick(function() {
      assert.equal(
        appLabel.$el.querySelector('li > a > span').innerHTML,
        model.appList[0].appData.image.ui_name
      );

      // Test stop button disabled
      assert.ok(
        appLabel.$el.querySelector('#stop-button').classList.contains('disabled')
      );

      // Simulate application running
      model.appList[0].status = 'RUNNING';

      // Test stop button enabled
      Vue.nextTick(function() {
        assert.notOk(
          appLabel.$el.querySelector('#stop-button').classList.contains('disabled')
        );

        done();
      });
    })
  });
});

@@ -162,35 +162,8 @@
 %22);%0A
-var $ = require(%22jquery%22);%0A
 requ
@@ -918,32 +918,33 @@
       %7D);%0A    %7D)
+;
 %0A  %7D);%0A%7D);%0A%0AQUni
@@ -1892,22 +1892,920 @@
     %7D);%0A
-
     %7D)
+;%0A  %7D);%0A%7D);%0A%0AQUnit.test(%22rendering share button%22, function (assert) %7B%0A  var done = assert.async();%0A%0A  var model = new ApplicationListModel();%0A  var appLabel = new ApplicationLabel(%7B%0A    data: function() %7B return %7B model: model %7D; %7D%0A  %7D).$mount();%0A%0A  model.update().done(function() %7B%0A    // Simulate application stopped%0A    model.appList%5B0%5D.status = 'STOPPED';%0A%0A    Vue.nextTick(function() %7B%0A      // Test share button disabled%0A      assert.ok(%0A        appLabel.$el.querySelector('#share-button').classList.contains('disabled')%0A      );%0A%0A      // Simulate application running%0A      model.appList%5B0%5D.status = 'RUNNING';%0A%0A      // Test share button disabled (Because clipboard save is not supported in test environment)%0A      Vue.nextTick(function() %7B%0A        assert.ok(%0A          appLabel.$el.querySelector('#share-button').classList.contains('disabled')%0A        );%0A%0A        done();%0A      %7D);%0A    %7D);
 %0A  %7D);%0A%7D

Add tests for the share button