Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

two tests in

  • Loading branch information...
commit eb25343109746be5b7619de70628fdf782d4b122 1 parent 827a90c
@iainjmitchell authored
Showing with 81 additions and 0 deletions.
  1. +30 −0 coffee/ShoppingKata_tests.coffee
  2. +51 −0 src/ShoppingKata_tests.js
View
30 coffee/ShoppingKata_tests.coffee
@@ -0,0 +1,30 @@
+vows = require 'vows'
+assert = require 'assert'
+
+vows.describe('checkout tests')
+ .addBatch(
+ 'no special offers':
+ 'when one A':
+ topic: () ->
+ new Checkout(@callback, 50).scan('A').total()
+ undefined
+ 'total is 50': (err, total) ->
+ assert.equal total, 50
+ 'when one B':
+ topic: () ->
+ new Checkout(@callback, 30).scan('B').total()
+ undefined
+ 'total is 30': (err, total) ->
+ assert.equal total, 30
+ )
+ .run()
+
+
+class Checkout
+ constructor: (@onTotal, @price) ->
+ scan: () -> this
+ total: () ->
+ console.log @onTotal
+ @onTotal undefined, @price
+
+
View
51 src/ShoppingKata_tests.js
@@ -0,0 +1,51 @@
+(function() {
+ var Checkout, assert, vows;
+
+ vows = require('vows');
+
+ assert = require('assert');
+
+ vows.describe('checkout tests').addBatch({
+ 'no special offers': {
+ 'when one A': {
+ topic: function() {
+ new Checkout(this.callback, 50).scan('A').total();
+ return;
+ },
+ 'total is 50': function(err, total) {
+ return assert.equal(total, 50);
+ }
+ },
+ 'when one B': {
+ topic: function() {
+ new Checkout(this.callback, 30).scan('B').total();
+ return;
+ },
+ 'total is 30': function(err, total) {
+ return assert.equal(total, 30);
+ }
+ }
+ }
+ }).run();
+
+ Checkout = (function() {
+
+ function Checkout(onTotal, price) {
+ this.onTotal = onTotal;
+ this.price = price;
+ }
+
+ Checkout.prototype.scan = function() {
+ return this;
+ };
+
+ Checkout.prototype.total = function() {
+ console.log(this.onTotal);
+ return this.onTotal(void 0, this.price);
+ };
+
+ return Checkout;
+
+ })();
+
+}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.