Skip to content

Commit

Permalink
Test added for spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncan Graham Walker committed May 21, 2016
1 parent 1dfec13 commit e93c164
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/styles/app.scss

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"ember-paper": "0.2.14",
"ember-resolver": "^2.0.3",
"ember-try": "^0.2.2",
"loader.js": "^4.0.1"
"loader.js": "^4.0.1",
"ember-tether": "0.3.1"
},
"keywords": [
"ember-addon",
Expand Down
39 changes: 39 additions & 0 deletions tests/integration/components/spacing-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

function assertSpacing(assert, context, expectedSpacing) {
const $this = context.$();
const targetPosition = $this.position();
const $tooltip = $this.find('.tooltip');
const tooltipPosition = $tooltip.position();
const offset = Math.floor(targetPosition.top - tooltipPosition.top);

const paddingTop = parseInt($tooltip.css('padding-top'));
const paddingBottom = parseInt($tooltip.css('padding-bottom'));

assert.equal(offset - paddingTop - paddingBottom, expectedSpacing,
`Tooltip should be ${expectedSpacing}px from the target`);

}

moduleForComponent('tooltip-on-component', 'Integration | Option | spacing', {
integration: true
});

test('It shows with showOn', function(assert) {

assert.expect(2);

/* Check the default spacing */

this.render(hbs`{{tooltip-on-component}}`);

assertSpacing(assert, this, 10);

/* Check custom spacing */

this.render(hbs`{{tooltip-on-component spacing=20}}`);

assertSpacing(assert, this, 20);

});
1 change: 0 additions & 1 deletion tests/integration/components/tooltip-on-element-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

Expand Down

0 comments on commit e93c164

Please sign in to comment.