Last active
September 4, 2019 21:00
-
-
Save vicsstar/246f91269dbb777c22d97e7207192762 to your computer and use it in GitHub Desktop.
Super Rentals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import EmberRouter from '@ember/routing/router'; | |
import config from './config/environment'; | |
const Router = EmberRouter.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('list-rentals'); | |
this.route('about'); | |
this.route('contact'); | |
this.route('rentals'); | |
}); | |
export default Router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
redirect() { | |
this.transitionTo('rentals'); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return [{ | |
id: 'grand-old-mansion', | |
title: 'Grand Old Mansion', | |
owner: 'Veruca Salt', | |
city: 'San Francisco', | |
category: 'Estate', | |
bedrooms: 15, | |
image: 'https://upload.wikimedia.org/wikipedia/commons/c/cb/Crane_estate_(5).jpg', | |
description: 'This grand old mansion sits on over 100 acres of rolling hills and dense redwood forests.' | |
}, { | |
id: 'urban-living', | |
title: 'Urban Living', | |
owner: 'Mike TV', | |
city: 'Seattle', | |
category: 'Condo', | |
bedrooms: 1, | |
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg', | |
description: 'A commuters dream. This rental is within walking distance of 2 bus stops and the Metro.' | |
}, { | |
id: 'downtown-charm', | |
title: 'Downtown Charm', | |
owner: 'Violet Beauregarde', | |
city: 'Portland', | |
category: 'Apartment', | |
bedrooms: 3, | |
image: 'https://upload.wikimedia.org/wikipedia/commons/f/f7/Wheeldon_Apartment_Building_-_Portland_Oregon.jpg', | |
description: 'Convenience is at your doorstep with this charming downtown rental. Great restaurants and active night life are within a few feet.' | |
}]; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { test } from 'qunit'; | |
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; | |
// import { click, visit, currentURL } from '@ember/test-helpers'; | |
moduleForAcceptance('List Rentals'); | |
test('should show /rentals as the home page', function(assert) { | |
visit('/'); | |
andThen(function() { | |
assert.equal(currentURL(), '/rentals', 'should redirect automatically'); | |
}); | |
}); | |
test('should link to information about the company', function(assert) { | |
visit('/'); | |
click('.menu-about'); | |
andThen(function() { | |
assert.equal(currentURL(), '/about', 'should go to about page'); | |
}); | |
}); | |
test('should show company\'s contact info. page', function(assert) { | |
visit('/'); | |
click('.menu-contact'); | |
andThen(function() { | |
assert.equal(currentURL(), '/contact', 'should go to contact page'); | |
}); | |
}); | |
test('should list available rentals', function(assert) { | |
visit('/'); | |
andThen(function() { | |
console.log(window); | |
const articles = this.element.querySelectorAll('article.listing'); | |
assert.equal(articles.length, 3, 'should display 3 listings'); | |
}.bind(this)); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { run } from '@ember/runloop'; | |
export default function destroyApp(application) { | |
run(application, 'destroy'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { module } from 'qunit'; | |
import { resolve } from 'rsvp'; | |
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) { | |
return options.beforeEach.apply(this, arguments); | |
} | |
}, | |
afterEach() { | |
let afterEach = options.afterEach && options.afterEach.apply(this, arguments); | |
return resolve(afterEach).then(() => destroyApp(this.application)); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import Application from '../../app'; | |
import config from '../../config/environment'; | |
const { run } = Ember; | |
const assign = Ember.assign || Ember.merge; | |
export default function startApp(attrs) { | |
let application; | |
let attributes = assign({rootElement: "#test-root"}, config.APP); | |
attributes.autoboot = true; | |
attributes = assign(attributes, attrs); // use defaults, but you can override; | |
run(() => { | |
application = Application.create(attributes); | |
application.setupForTesting(); | |
application.injectTestHelpers(); | |
}); | |
return application; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Application from '../app'; | |
import config from '../config/environment'; | |
import { setApplication } from '@ember/test-helpers'; | |
import { start } from 'ember-qunit'; | |
import { assign } from '@ember/polyfills'; | |
let attributes = assign({ rootElement: '#main' }, config.APP); | |
setApplication(Application.create(attributes)); | |
start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": true | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment