|
| 1 | +BookStore = require 'book_store' |
| 2 | + |
| 3 | +describe 'book-store', -> |
| 4 | + it 'Only a single book', -> |
| 5 | + result = BookStore.total {1} |
| 6 | + expected = 800 |
| 7 | + assert.are.equal expected, result |
| 8 | + |
| 9 | + pending 'Two of the same book', -> |
| 10 | + result = BookStore.total {2, 2} |
| 11 | + expected = 1600 |
| 12 | + assert.are.equal expected, result |
| 13 | + |
| 14 | + pending 'Empty basket', -> |
| 15 | + result = BookStore.total {} |
| 16 | + expected = 0 |
| 17 | + assert.are.equal expected, result |
| 18 | + |
| 19 | + pending 'Two different books', -> |
| 20 | + result = BookStore.total {1, 2} |
| 21 | + expected = 1520 |
| 22 | + assert.are.equal expected, result |
| 23 | + |
| 24 | + pending 'Three different books', -> |
| 25 | + result = BookStore.total {1, 2, 3} |
| 26 | + expected = 2160 |
| 27 | + assert.are.equal expected, result |
| 28 | + |
| 29 | + pending 'Four different books', -> |
| 30 | + result = BookStore.total {1, 2, 3, 4} |
| 31 | + expected = 2560 |
| 32 | + assert.are.equal expected, result |
| 33 | + |
| 34 | + pending 'Five different books', -> |
| 35 | + result = BookStore.total {1, 2, 3, 4, 5} |
| 36 | + expected = 3000 |
| 37 | + assert.are.equal expected, result |
| 38 | + |
| 39 | + pending 'Two groups of four is cheaper than group of five plus group of three', -> |
| 40 | + result = BookStore.total {1, 1, 2, 2, 3, 3, 4, 5} |
| 41 | + expected = 5120 |
| 42 | + assert.are.equal expected, result |
| 43 | + |
| 44 | + pending 'Two groups of four is cheaper than groups of five and three', -> |
| 45 | + result = BookStore.total {1, 1, 2, 3, 4, 4, 5, 5} |
| 46 | + expected = 5120 |
| 47 | + assert.are.equal expected, result |
| 48 | + |
| 49 | + pending 'Group of four plus group of two is cheaper than two groups of three', -> |
| 50 | + result = BookStore.total {1, 1, 2, 2, 3, 4} |
| 51 | + expected = 4080 |
| 52 | + assert.are.equal expected, result |
| 53 | + |
| 54 | + pending 'Two each of first four books and one copy each of rest', -> |
| 55 | + result = BookStore.total {1, 1, 2, 2, 3, 3, 4, 4, 5} |
| 56 | + expected = 5560 |
| 57 | + assert.are.equal expected, result |
| 58 | + |
| 59 | + pending 'Two copies of each book', -> |
| 60 | + result = BookStore.total {1, 1, 2, 2, 3, 3, 4, 4, 5, 5} |
| 61 | + expected = 6000 |
| 62 | + assert.are.equal expected, result |
| 63 | + |
| 64 | + pending 'Three copies of first book and two each of remaining', -> |
| 65 | + result = BookStore.total {1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1} |
| 66 | + expected = 6800 |
| 67 | + assert.are.equal expected, result |
| 68 | + |
| 69 | + pending 'Three each of first two books and two each of remaining books', -> |
| 70 | + result = BookStore.total {1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2} |
| 71 | + expected = 7520 |
| 72 | + assert.are.equal expected, result |
| 73 | + |
| 74 | + pending 'Four groups of four are cheaper than two groups each of five and three', -> |
| 75 | + result = BookStore.total {1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5} |
| 76 | + expected = 10240 |
| 77 | + assert.are.equal expected, result |
| 78 | + |
| 79 | + pending 'Check that groups of four are created properly even when there are more groups of three than groups of five', -> |
| 80 | + result = BookStore.total {1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5} |
| 81 | + expected = 14560 |
| 82 | + assert.are.equal expected, result |
| 83 | + |
| 84 | + pending 'One group of one and four is cheaper than one group of two and three', -> |
| 85 | + result = BookStore.total {1, 1, 2, 3, 4} |
| 86 | + expected = 3360 |
| 87 | + assert.are.equal expected, result |
| 88 | + |
| 89 | + pending 'One group of one and two plus three groups of four is cheaper than one group of each size', -> |
| 90 | + result = BookStore.total {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5} |
| 91 | + expected = 10000 |
| 92 | + assert.are.equal expected, result |
0 commit comments