Skip to content

Commit

Permalink
use Ember.findBy so Array.prototype.find works in Phantom
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianSipple authored and BrianSipple committed Jun 21, 2016
1 parent 2ee1e60 commit 2603a3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
17 changes: 11 additions & 6 deletions tests/acceptance/violations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { test } from 'qunit';
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';
import sinon from 'sinon';

let actual, expected, sandbox;
const { A } = Ember;

const IDs = {
emptyButton: '#empty-button',
sloppyInput: '#sloppy-input'
};

const findBy = (items, key, val) => items.find(item => item[key] === val);

let actual, expected, sandbox;

moduleForAcceptance('Acceptance | violations', {
beforeEach() {
Expand All @@ -25,12 +26,16 @@ moduleForAcceptance('Acceptance | violations', {
test('marking DOM nodes with violations', function(assert) {

sandbox.stub(axe.ember, 'a11yCheckCallback', function (results) {
console.log('Results****', results.violations.find);
assert.equal(results.violations.length, 2);
actual = results.violations.length;
expected = 2;

assert.equal(actual, expected);

const buttonNameViolation = findBy(results.violations, 'id', 'button-name');
assert.equal(buttonNameViolation.nodes[0].target[0], IDs.emptyButton);
const buttonNameViolation = A(results.violations).findBy('id', 'button-name');
actual = buttonNameViolation.nodes[0].target[0];
expected = IDs.emptyButton;

assert.equal(actual, expected);
});

visit('/violations');
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/instance-initializers/axe-component-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global sinon, axe */
import Ember from 'ember';
import { initialize } from 'dummy/instance-initializers/axe-component';
import { module, test, skip } from 'qunit';
import { module, test } from 'qunit';

const { Application, Component, Logger, run } = Ember;

Expand Down Expand Up @@ -188,7 +188,7 @@ test('custom classNames are set on the violating elmenet if they are defined', f
document.body.appendChild(dummyDOMNode);

// run(() => component.appendTo('#ember-testing'));
let a11yCheckStub = sandbox.stub(axe, 'a11yCheck', function(el, options, callback) {
sandbox.stub(axe, 'a11yCheck', function(el, options, callback) {
callback({
violations: [{
name: 'test',
Expand Down Expand Up @@ -218,7 +218,7 @@ test(`the component defaults to setting the \`axe-violation\` class on
document.body.appendChild(dummyDOMNode);

// run(() => component.appendTo('#ember-testing'));
let a11yCheckStub = sandbox.stub(axe, 'a11yCheck', function(el, options, callback) {
sandbox.stub(axe, 'a11yCheck', function(el, options, callback) {
callback({
violations: [{
name: 'test',
Expand Down

0 comments on commit 2603a3a

Please sign in to comment.