Last active
July 18, 2016 21:32
-
-
Save phillipkregg/e48f406138bba9a5d70960a4a78da71f to your computer and use it in GitHub Desktop.
Shopping Cart Test
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.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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.Service.extend({ | |
items: [], | |
add(item) { | |
var items = this.get('items'); | |
debugger; | |
items.push(item); | |
//return item; | |
} | |
}); |
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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} |
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 Resolver from '../../resolver'; | |
import config from '../../config/environment'; | |
const resolver = Resolver.create(); | |
resolver.namespace = { | |
modulePrefix: config.modulePrefix, | |
podModulePrefix: config.podModulePrefix | |
}; | |
export default resolver; |
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 resolver from './helpers/resolver'; | |
import { | |
setResolver | |
} from 'ember-qunit'; | |
setResolver(resolver); |
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 { moduleFor, test } from 'ember-qunit'; | |
moduleFor('service:shopping-cart', 'Unit | Service | cart', { | |
beforeEach() { | |
var cart = this.subject(); | |
cart.set('items', []); | |
} | |
}); | |
// Replace this with your real tests. | |
test('it exists', function(assert) { | |
let service = this.subject(); | |
assert.ok(service); | |
}); | |
test('add() adds item to cart', function(assert) { | |
var cart = this.subject(); | |
cart.add({ id: 1, product: 'movie 1', quantity: 1 }); | |
cart.add({ id: 2, product: 'movie 2', quantity: 1 }); | |
console.log(cart.get('items')); | |
assert.deepEqual(cart.get('items'), [ | |
{ id: 1, product: 'movie 1', quantity: 1 }, | |
{ id: 2, product: 'movie 2', quantity: 1 } | |
]) | |
}); | |
test('add() - updates the quantity by 1 when a duplicate item is added to the cart', function() { | |
var cart = this.subject(); | |
var items; | |
cart.add({ id: 1, product: 'movie 1' }); | |
cart.add({ id: 1, product: 'movie 1' }); | |
items = JSON.parse(window.sessionStorage.getItem('cart-test')); | |
}); |
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.10.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": true | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.6.0", | |
"ember-data": "2.6.1", | |
"ember-template-compiler": "2.6.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment