Fix tests
This commit is contained in:
parent
f9dde74f59
commit
93deb7f4e2
|
@ -1,4 +1,5 @@
|
|||
import Ember from 'ember';
|
||||
import config from 'travis/config/environment';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
actions: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Ember from 'ember';
|
||||
import JSONSerializer from 'ember-data/serializers/json'
|
||||
import JSONSerializer from 'ember-data/serializers/json';
|
||||
|
||||
var traverse = function(object, callback) {
|
||||
if(!object) {
|
||||
|
|
|
@ -2,6 +2,7 @@ import Ember from 'ember';
|
|||
import { moduleForComponent, test } from 'ember-qunit';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import fillIn from '../../helpers/fill-in';
|
||||
import DS from 'ember-data';
|
||||
|
||||
|
||||
moduleForComponent('add-env-var', 'Integration | Component | add env-var', {
|
||||
|
@ -11,12 +12,14 @@ moduleForComponent('add-env-var', 'Integration | Component | add env-var', {
|
|||
test('it adds an env var on submit', function(assert) {
|
||||
assert.expect(6);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
assert.equal(store.all('envVar').get('length'), 0, 'precond: store should be empty');
|
||||
// this shouldn't be needed, probably some bug in tests setup with new ember-data
|
||||
this.registry.register('transform:boolean', DS.BooleanTransform);
|
||||
var store = this.container.lookup('service:store');
|
||||
assert.equal(store.peekAll('envVar').get('length'), 0, 'precond: store should be empty');
|
||||
|
||||
var repo;
|
||||
Ember.run(function() {
|
||||
repo = store.push('repo', {id: 1, slug: 'travis-ci/travis-web'});
|
||||
repo = store.push({ data: { id: 1, type: 'repo', attributes: { slug: 'travis-ci/travis-web'}}});
|
||||
});
|
||||
|
||||
this.set('repo', repo);
|
||||
|
@ -28,9 +31,9 @@ test('it adds an env var on submit', function(assert) {
|
|||
|
||||
this.$('.form-submit').click();
|
||||
|
||||
assert.equal(store.all('envVar').get('length'), 1, 'env var should be added to store');
|
||||
assert.equal(store.peekAll('envVar').get('length'), 1, 'env var should be added to store');
|
||||
|
||||
var envVar = store.all('envVar').objectAt(0);
|
||||
var envVar = store.peekAll('envVar').objectAt(0);
|
||||
|
||||
assert.equal(envVar.get('name'), 'FOO', 'name should be set for the env var');
|
||||
assert.equal(envVar.get('value'), 'bar', 'value should be set for the env var');
|
||||
|
@ -62,12 +65,13 @@ test('it shows an error if no name is present', function(assert) {
|
|||
test('it adds a public env var on submit', function(assert) {
|
||||
assert.expect(6);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
assert.equal(store.all('envVar').get('length'), 0, 'precond: store should be empty');
|
||||
this.registry.register('transform:boolean', DS.BooleanTransform);
|
||||
var store = this.container.lookup('service:store');
|
||||
assert.equal(store.peekAll('envVar').get('length'), 0, 'precond: store should be empty');
|
||||
|
||||
var repo;
|
||||
Ember.run(function() {
|
||||
repo = store.push('repo', {id: 1, slug: 'travis-ci/travis-web'});
|
||||
repo = store.push({data: { id: 1, type: 'repo', attributes: { slug: 'travis-ci/travis-web'}}});
|
||||
});
|
||||
|
||||
this.set('repo', repo);
|
||||
|
@ -81,9 +85,9 @@ test('it adds a public env var on submit', function(assert) {
|
|||
|
||||
this.$('.form-submit').click();
|
||||
|
||||
assert.equal(store.all('envVar').get('length'), 1, 'env var should be added to store');
|
||||
assert.equal(store.peekAll('envVar').get('length'), 1, 'env var should be added to store');
|
||||
|
||||
var envVar = store.all('envVar').objectAt(0);
|
||||
var envVar = store.peekAll('envVar').objectAt(0);
|
||||
|
||||
assert.equal(envVar.get('name'), 'FOO', 'name should be set for the env var');
|
||||
assert.equal(envVar.get('value'), 'bar', 'value should be set for the env var');
|
||||
|
|
|
@ -2,7 +2,7 @@ import Ember from 'ember';
|
|||
import { moduleForComponent, test } from 'ember-qunit';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import fillIn from '../../helpers/fill-in';
|
||||
|
||||
import DS from 'ember-data';
|
||||
|
||||
moduleForComponent('add-ssh-key', 'Integration | Component | add ssh-key', {
|
||||
integration: true
|
||||
|
@ -11,18 +11,19 @@ moduleForComponent('add-ssh-key', 'Integration | Component | add ssh-key', {
|
|||
test('it adds an ssh key on submit', function(assert) {
|
||||
assert.expect(6);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
this.registry.register('transform:boolean', DS.BooleanTransform);
|
||||
var store = this.container.lookup('service:store');
|
||||
|
||||
var repo;
|
||||
Ember.run(function() {
|
||||
repo = store.push('repo', {id: 1, slug: 'travis-ci/travis-web'});
|
||||
repo = store.push({data: { id: 1, type: 'repo', attributes: { slug: 'travis-ci/travis-web'}}});
|
||||
});
|
||||
|
||||
this.set('repo', repo);
|
||||
|
||||
this.render(hbs`{{add-ssh-key repo=repo sshKeyAdded="sshKeyAdded"}}`);
|
||||
|
||||
var sshKey = store.all('ssh_key').objectAt(0);
|
||||
var sshKey = store.peekAll('ssh_key').objectAt(0);
|
||||
|
||||
assert.ok(! sshKey.get('description'), 'description should be blank');
|
||||
assert.ok(! sshKey.get('value'), 'value should be blank');
|
||||
|
@ -45,18 +46,19 @@ test('it adds an ssh key on submit', function(assert) {
|
|||
test('it throws an error if value for ssh key is blank', function(assert) {
|
||||
assert.expect(5);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
this.registry.register('transform:boolean', DS.BooleanTransform);
|
||||
var store = this.container.lookup('service:store');
|
||||
|
||||
var repo;
|
||||
Ember.run(function() {
|
||||
repo = store.push('repo', {id: 1, slug: 'travis-ci/travis-web'});
|
||||
repo = store.push({data: { id: 1, type: 'repo', attributes: { slug: 'travis-ci/travis-web'}}});
|
||||
});
|
||||
|
||||
this.set('repo', repo);
|
||||
|
||||
this.render(hbs`{{add-ssh-key repo=repo sshKeyAdded="sshKeyAdded"}}`);
|
||||
|
||||
var sshKey = store.all('ssh_key').objectAt(0);
|
||||
var sshKey = store.peekAll('ssh_key').objectAt(0);
|
||||
|
||||
assert.ok(! sshKey.get('description'), 'description should be blank');
|
||||
assert.ok(! sshKey.get('value'), 'value should be blank');
|
||||
|
|
|
@ -2,6 +2,7 @@ import Ember from 'ember';
|
|||
import { moduleForComponent, test } from 'ember-qunit';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import fillIn from '../../helpers/fill-in';
|
||||
import DS from 'ember-data';
|
||||
|
||||
|
||||
moduleForComponent('env-var', 'Integration | Component | env-var', {
|
||||
|
@ -11,9 +12,10 @@ moduleForComponent('env-var', 'Integration | Component | env-var', {
|
|||
test('it renders an env-var with private value', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
this.registry.register('transform:boolean', DS.BooleanTransform);
|
||||
var store = this.container.lookup('service:store');
|
||||
Ember.run(() => {
|
||||
var envVar = store.push('envVar', {id: 1, name: 'foo', value: 'bar', public: false});
|
||||
var envVar = store.push({data: { id: 1, type: 'env-var', attributes: { name: 'foo', value: 'bar', public: false}}});
|
||||
this.set('envVar', envVar);
|
||||
});
|
||||
|
||||
|
@ -27,23 +29,24 @@ test('it renders an env-var with private value', function(assert) {
|
|||
test('it renders an env-var with public value', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
this.registry.register('transform:boolean', DS.BooleanTransform);
|
||||
var store = this.container.lookup('service:store');
|
||||
Ember.run(() => {
|
||||
var envVar = store.push('envVar', {id: 1, name: 'foo', value: 'bar', public: true});
|
||||
var envVar = store.push({data: { id: 1, type: 'env-var', attributes: { name: 'foo', value: 'bar', public: true}}});
|
||||
this.set('envVar', envVar);
|
||||
});
|
||||
|
||||
this.render(hbs`{{env-var envVar=envVar}}`);
|
||||
|
||||
assert.equal(this.$('.env-var-name').text(), 'foo', 'name should be displayed');
|
||||
assert.equal(this.$('.env-var-value input').val(), 'bar', 'value should be hidden');
|
||||
assert.equal(this.$('.env-var-value input').val(), 'bar', 'value should not be hidden');
|
||||
|
||||
});
|
||||
|
||||
// test('it deletes an env-var', function(assert) {
|
||||
// assert.expect(2);
|
||||
|
||||
// var store = this.container.lookup('store:main');
|
||||
// var store = this.container.lookup('service:store');
|
||||
// Ember.run(() => {
|
||||
// var envVar = store.push('envVar', {id: 1, name: 'foo', value: 'bar', public: true});
|
||||
// this.set('envVar', envVar);
|
||||
|
@ -51,10 +54,10 @@ test('it renders an env-var with public value', function(assert) {
|
|||
|
||||
// this.render(hbs`{{env-var envVar=envVar}}`);
|
||||
|
||||
// assert.equal(store.all('envVar').get('length'), 1, 'precond: store should have an env-var');
|
||||
// assert.equal(store.peekAll('envVar').get('length'), 1, 'precond: store should have an env-var');
|
||||
|
||||
// this.$('.env-var-action a').click();
|
||||
|
||||
// assert.equal(store.all('envVar').get('length'), 0, 'env-var should be deleted');
|
||||
// assert.equal(store.peekAll('envVar').get('length'), 0, 'env-var should be deleted');
|
||||
|
||||
// });
|
||||
|
|
|
@ -11,7 +11,7 @@ moduleForComponent('ssh-key', 'Integration | Component | ssh-key', {
|
|||
test('it renders the default ssh key if no custom key is set', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
var store = this.container.lookup('service:store');
|
||||
|
||||
var key = Ember.Object.create({fingerprint: 'fingerprint'});
|
||||
this.set('key', key);
|
||||
|
@ -25,11 +25,11 @@ test('it renders the default ssh key if no custom key is set', function(assert)
|
|||
test('it renders the custom ssh key if custom key is set', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
var store = this.container.lookup('service:store');
|
||||
|
||||
var key;
|
||||
Ember.run(function() {
|
||||
key = store.push('sshKey', {description: 'fookey', fingerprint: 'somethingthing', id: 1});
|
||||
key = store.push({data: { id: 1, type: 'ssh-key', attributes: { description: 'fookey', fingerprint: 'somethingthing' }}});
|
||||
});
|
||||
|
||||
this.set('key', key);
|
||||
|
@ -44,11 +44,11 @@ test('it renders the custom ssh key if custom key is set', function(assert) {
|
|||
test('it deletes a custom key if permissions are right', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
var store = this.container.lookup('service:store');
|
||||
|
||||
var key;
|
||||
Ember.run(function() {
|
||||
key = store.push('sshKey', {description: 'fookey', fingerprint: 'somethingthing', id: 1});
|
||||
key = store.push({data: { id: 1, type: 'ssh-key', attributes: { description: 'fookey', fingerprint: 'somethingthing' }}});
|
||||
});
|
||||
|
||||
this.set('key', key);
|
||||
|
@ -67,11 +67,11 @@ test('it deletes a custom key if permissions are right', function(assert) {
|
|||
test('it does not delete the custom key if permissions are insufficient', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var store = this.container.lookup('store:main');
|
||||
var store = this.container.lookup('service:store');
|
||||
|
||||
var key;
|
||||
Ember.run(function() {
|
||||
key = store.push('sshKey', {description: 'fookey', fingerprint: 'somethingthing', id: 1});
|
||||
key = store.push({data: { id: 1, type: 'ssh-key', attributes: { description: 'fookey', fingerprint: 'somethingthing' }}});
|
||||
});
|
||||
|
||||
this.set('key', key);
|
||||
|
|
Loading…
Reference in New Issue
Block a user