import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('file-editor-column', 'Integration | Component | file editor column', {
  integration: true
});

test('it calls addColumn when the add column glyph is clicked', function(assert) {
  assert.expect(1);

  this.set('externalAction', () => {
    assert.ok(true, 'addColumn action was called');
  });

  this.render(hbs`
    {{file-editor-column col='2' numColumns=2 addColumn=(action externalAction)}}
  `);

  this.$('.glyphicon-plus').click();
});

test('it calls removeColumn when the remove column glyph is clicked', function(assert) {
  assert.expect(1);

  this.set('externalAction', () => {
    assert.ok(true, 'removeColumn action was called');
  });

  this.render(hbs`
    {{file-editor-column col='2' removeColumn=(action externalAction)}}
  `);

  this.$('.glyphicon-remove').click();
});

test('it calls showFileTree when the show file tree glyph is clicked', function(assert) {
  assert.expect(1);

  this.set('externalAction', () => {
    assert.ok(true, 'showFileTree action was called');
  });

  this.render(hbs`
    {{file-editor-column col='1' fileTreeShown=false showFileTree=(action externalAction)}}
  `);

  this.$('.glyphicon-chevron-right').click();
});

@@ -1275,24 +1275,1059 @@
 on-right').click();%0A%7D);%0A
+%0Atest('it calls contentsChanged when changing the content via the code editor', function(assert) %7B%0A  assert.expect(1);%0A  const enterKeyEvent = %7B keyCode: 3 %7D;%0A%0A  this.set('externalAction', () =%3E %7B%0A    assert.ok(true, 'contentsChanged action was called');%0A  %7D);%0A%0A  this.set('file', %7B content: '' %7D);%0A%0A  this.render(hbs%60%0A    %7B%7Bfile-editor-column col='1' file=file contentsChanged=(action externalAction)%7D%7D%0A  %60);%0A%0A  const codeMirrorInstance = this.$('.CodeMirror')%5B0%5D.CodeMirror;%0A  codeMirrorInstance.triggerOnKeyDown(enterKeyEvent);%0A%7D);%0A%0Atest('it does not call contentsChanged when changing the content programatically', function(assert) %7B%0A  assert.expect(1);%0A  let externalNotCalled = true;%0A%0A  this.set('externalAction', () =%3E %7B%0A    externalNotCalled = false;%0A  %7D);%0A%0A  this.set('file', %7B content: '' %7D);%0A%0A  this.render(hbs%60%0A    %7B%7Bfile-editor-column col='1' file=file contentsChanged=(action externalAction)%7D%7D%0A  %60);%0A%0A  this.set('file.content', 'new content');%0A  assert.ok(externalNotCalled, 'contentsChanged action was not called');%0A%7D);%0A

test file editor colulmn contentsChanged action