parent
75b75358cd
commit
253aac1fd4
27 changed files with 187 additions and 73 deletions
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"predef": [
|
||||
"setBreakpoint",
|
||||
"document",
|
||||
"window",
|
||||
"location",
|
||||
|
|
60
tests/helpers/responsive.js
Normal file
60
tests/helpers/responsive.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
import Ember from 'ember';
|
||||
import MediaService from 'ember-responsive/media';
|
||||
|
||||
const {
|
||||
getOwner
|
||||
} = Ember;
|
||||
const { classify } = Ember.String;
|
||||
|
||||
MediaService.reopen({
|
||||
// Change this if you want a different default breakpoint in tests.
|
||||
_defaultBreakpoint: 'desktop',
|
||||
|
||||
_breakpointArr: Ember.computed('breakpoints', function() {
|
||||
return Object.keys(this.get('breakpoints')) || Ember.A([]);
|
||||
}),
|
||||
|
||||
_forceSetBreakpoint(breakpoint) {
|
||||
let found = false;
|
||||
|
||||
const props = {};
|
||||
this.get('_breakpointArr').forEach(function(bp) {
|
||||
const val = bp === breakpoint;
|
||||
if (val) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
props[`is${classify(bp)}`] = val;
|
||||
});
|
||||
|
||||
if (found) {
|
||||
this.setProperties(props);
|
||||
} else {
|
||||
throw new Error(
|
||||
`You tried to set the breakpoint to ${breakpoint}, which is not in your app/breakpoint.js file.`
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
match() {}, // do not set up listeners in test
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
this._forceSetBreakpoint(this.get('_defaultBreakpoint'));
|
||||
}
|
||||
});
|
||||
|
||||
export default Ember.Test.registerAsyncHelper('setBreakpoint', function(app, breakpoint) {
|
||||
// this should use getOwner once that's supported
|
||||
const mediaService = app.__deprecatedInstance__.lookup('service:media');
|
||||
mediaService._forceSetBreakpoint(breakpoint);
|
||||
});
|
||||
|
||||
export function setBreakpointForIntegrationTest(container, breakpoint) {
|
||||
const mediaService = getOwner(container).lookup('service:media');
|
||||
mediaService._forceSetBreakpoint(breakpoint);
|
||||
container.set('media', mediaService);
|
||||
|
||||
return mediaService;
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
import resolver from './helpers/resolver';
|
||||
import './helpers/responsive';
|
||||
|
||||
import './helpers/flash-message';
|
||||
import {
|
||||
setResolver
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('controller:login', 'Unit | Controller | login', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.subject();
|
||||
assert.ok(controller);
|
||||
});
|
|
@ -1,11 +0,0 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:application', 'Unit | Route | application', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
});
|
|
@ -1,11 +0,0 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:index', 'Unit | Route | index', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
});
|
|
@ -1,11 +0,0 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:login', 'Unit | Route | login', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue