Skip to content

Commit

Permalink
test for geolocation
Browse files Browse the repository at this point in the history
addresses #330
  • Loading branch information
kjgarza committed Mar 17, 2020
1 parent 64fcd96 commit d2b4980
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 5 deletions.
17 changes: 16 additions & 1 deletion tests/acceptance/client_admin/doi-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
currentURL,
// findAll,
visit,
// fillIn,
fillIn,
// waitFor,
// click,
// typeIn,
Expand Down Expand Up @@ -108,6 +108,21 @@ module('Acceptance | client_admin | repository', function(hooks) {
assert.dom('[doi-subject]').includesText('Materials engineering');
});

test('visiting the Form and adding geoLocationPlace', async function(assert) {
await authenticateSession({
uid: 'datacite.rph',
name: 'Alfred Wegener Institute',
role_id: 'client_admin',
provider_id: 'datacite',
client_id: 'datacite.rph',
});
await visit('repositories/datacite.rph/dois/new');

await fillIn('[data-test-geo-location-place]', 'Amsterdam, Novoravis hotel');

assert.dom('[data-test-geo-location-place]').hasValue('Amsterdam, Novoravis hotel');
});

test('visiting the Form and entering new subject', async function(assert) {
await authenticateSession({
uid: 'datacite.rph',
Expand Down
8 changes: 4 additions & 4 deletions tests/acceptance/staff_admin/doi-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module('Acceptance | staff_admin | admin', function(hooks) {
// });

test('new DOI form for repository RPH', async function(assert) {
assert.expect(17);
assert.expect(18);

await visit('/repositories/datacite.rph/dois/new');

Expand All @@ -79,7 +79,7 @@ module('Acceptance | staff_admin | admin', function(hooks) {
assert.dom('[data-test-given-name]').exists();
assert.dom('[data-test-family-name]').exists();
assert.dom('[data-test-name]').exists();

assert.dom('[data-test-geo-location-place]').exists();
assert.dom('[data-test-title]').exists();
assert.dom('input#publisher-field').exists();
assert.dom('input#publication-year-field').exists();
Expand Down Expand Up @@ -110,7 +110,7 @@ module('Acceptance | staff_admin | admin', function(hooks) {
});

test('edit DOI form for repository RPH', async function(assert) {
assert.expect(17);
assert.expect(18);

await visit('/dois/10.70048%2Fe605-dg05/edit');

Expand All @@ -125,7 +125,7 @@ module('Acceptance | staff_admin | admin', function(hooks) {
assert.dom('[data-test-given-name]').exists();
assert.dom('[data-test-family-name]').exists();
assert.dom('[data-test-name]').exists();

assert.dom('[data-test-geo-location-place]').exists();
assert.dom('[data-test-title]').exists();
assert.dom('input#publisher-field').exists();
assert.dom('input#publication-year-field').exists();
Expand Down
7 changes: 7 additions & 0 deletions tests/factories/doi.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ FactoryGuy.define('doi', {
contributors: FactoryGuy.hasMany('contributor'),
titles: FactoryGuy.hasMany('title'),
descriptions: FactoryGuy.hasMany('description'),
geoLocations: FactoryGuy.hasMany('geoLocation'),
subjects: FactoryGuy.hasMany('subject'),
publisher: 'Royal Society of Chemistry',
types: {
Expand Down Expand Up @@ -67,6 +68,12 @@ FactoryGuy.define('description', {
},
});

FactoryGuy.define('geoLocation', {
default: {
geoLocationPlace: 'Mexico',
},
});

FactoryGuy.define('subject', {
default: {
subject: 'Clinical medicine',
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/components/doi-geo-location-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
// import { selectChoose } from 'ember-power-select/test-support';
import { setupFactoryGuy, make } from 'ember-data-factory-guy';

module('Integration | Component | doi geo-location', function(hooks) {
setupRenderingTest(hooks);
setupFactoryGuy(hooks);

test('it renders', async function(assert) {
this.set('model', make('doi'));
this.set('fragment', make('geoLocation'));
await render(hbs`{{doi-geo-location model=model fragment=fragment index=0}}`);

assert.dom('*').hasText('GeoLocation Place (optional) Description of a geographic location.');
});
});
34 changes: 34 additions & 0 deletions tests/integration/components/doi-geo-locations-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupFactoryGuy, make } from 'ember-data-factory-guy';
import { render, fillIn, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | doi geo-locations', function(hooks) {
setupRenderingTest(hooks);
setupFactoryGuy(hooks);

test('it renders', async function(assert) {
this.set('model', make('doi'));
await render(hbs`{{doi-geo-locations model=model}}`);
await click('#add-geolocation');
let geoLocations = this.element.querySelectorAll('input.geo-location-place-field');

await fillIn(geoLocations[0], 'Chihuahahu, Mexico, 1890');
assert.dom(geoLocations[0]).hasValue('Chihuahahu, Mexico, 1890');
});

test('add multiple values', async function(assert) {
this.set('model', make('doi'));
await render(hbs`{{doi-geo-locations model=model}}`);
await click('#add-geolocation');
await click('#add-geolocation');
let geoLocations = this.element.querySelectorAll('input.geo-location-place-field');

await fillIn(geoLocations[0], 'motzstrasse 56, berlin');
await fillIn(geoLocations[1], 'Chihuahahu, Mexico, 1890');

assert.dom(geoLocations[0]).hasValue('motzstrasse 56, berlin');
assert.dom(geoLocations[1]).hasValue('Chihuahahu, Mexico, 1890');
});
});

0 comments on commit d2b4980

Please sign in to comment.