Skip to content

Instantly share code, notes, and snippets.

@samselikoff
Last active February 1, 2017 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samselikoff/2df6c9987df4a21f404eb67a7b3dc017 to your computer and use it in GitHub Desktop.
Save samselikoff/2df6c9987df4a21f404eb67a7b3dc017 to your computer and use it in GitHub Desktop.
Posters mirage
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findAll('book');
},
});
<div class='Books'>
{{#each model as |book|}}
<a href="{{href-to 'book' book}}" class='Book'>
Hi!
</a>
{{/each}}
</div>
export default function() {
this.get('books');
};
import { Model } from 'ember-cli-mirage';
export default Model.extend({
});
export default function(server) {
// added this line because global wasn't created otherwise.
server.createList('book', 10);
}
import { JSONAPISerializer } from 'ember-cli-mirage';
export default JSONAPISerializer.extend({
});
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr()
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('book', { path: '/:book_id' });
});
export default Router;
body {
margin: 0;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.Books {
display: flex;
flex-wrap: wrap;
}
.Book {
border: 1px solid #ddd;
flex-basis: 33%;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
background: whitesmoke;
}
import { test } from 'qunit';
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | Users');
test('I can see the users', function(assert) {
server.create('user', { name: 'Link' });
//visit('/');
andThen(function() {
assert.ok(true);
//assert.ok(find(':contains(Welcome Link!)').length);
});
});
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import { module } from 'qunit';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
export default function(name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
if (options.beforeEach) {
options.beforeEach.apply(this, arguments);
}
},
afterEach() {
if (options.afterEach) {
options.afterEach.apply(this, arguments);
}
destroyApp(this.application);
}
});
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
export default function startApp(attrs) {
let application;
let attributes = Ember.merge({rootElement: "#test-root"}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
Ember.run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.11.0",
"ENV": {
"ember-cli-mirage": {
"enabled": true
}
},
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {
"ember-href-to": "1.11.1",
"ember-cli-mirage": "0.3.0-beta.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment