Commit b0c86f25f827fd9bb17057b7017780ff5d6f36ff
1 parent
46a41fff
Exists in
master
and in
8 other branches
Added 2 unit tests
Showing
2 changed files
with
68 additions
and
26 deletions
Show diff stats
test/SpecRunner.html
@@ -7,27 +7,44 @@ | @@ -7,27 +7,44 @@ | ||
7 | <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.2.0/jasmine_favicon.png"> | 7 | <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.2.0/jasmine_favicon.png"> |
8 | <link rel="stylesheet" href="lib/jasmine-2.2.0/jasmine.css"> | 8 | <link rel="stylesheet" href="lib/jasmine-2.2.0/jasmine.css"> |
9 | 9 | ||
10 | - | ||
11 | - | ||
12 | - <script src="lib/jasmine-2.2.0/jasmine.js"></script> | ||
13 | - <script src="lib/jasmine-2.2.0/jasmine-html.js"></script> | 10 | + <!-- // <script src="lib/jasmine-2.2.0/jasmine.js"></script> |
11 | + // <script src="lib/jasmine-2.2.0/jasmine-html.js"></script> --> | ||
14 | <!-- // <script src="lib/jasmine-2.2.0/boot.js"></script> --> | 12 | <!-- // <script src="lib/jasmine-2.2.0/boot.js"></script> --> |
15 | 13 | ||
16 | <script type="text/javascript"> | 14 | <script type="text/javascript"> |
17 | 15 | ||
18 | - // var require = { | ||
19 | - // paths: { | ||
20 | - // "domReady": "lib/requirejs-plugins/domReady", | ||
21 | - // "model": "../js", | ||
22 | - // "handlebars": '../js/handlebars-v3.0.1', | ||
23 | - // "handlebars_helpers": '../js/handlebars-helpers', | ||
24 | - // "jquery":'../js/jquery-2.1.3.min' | ||
25 | - // } | ||
26 | - // }; | 16 | + var require = { |
17 | + paths: { | ||
18 | + "domReady": "lib/requirejs-plugins/domReady", | ||
19 | + "model": "../js", | ||
20 | + "handlebars": '../js/handlebars-v3.0.1', | ||
21 | + "handlebars_helpers": '../js/handlebars-helpers', | ||
22 | + "jquery":'../js/jquery-2.1.3.min', | ||
23 | + "jquery_cookie":'../js/jquery.cookie', | ||
24 | + "jasmine":'lib/jasmine-2.2.0/jasmine', | ||
25 | + "jasmine-html":'lib/jasmine-2.2.0/jasmine-html', | ||
26 | + "jasmine-jquery":'lib/jasmine-plugins/jasmine-jquery', | ||
27 | + "jasmine-boot":'lib/jasmine-2.2.0/boot' | ||
28 | + }, | ||
29 | + shim:{ | ||
30 | + jasmine:{ | ||
31 | + exports: 'jasmine' | ||
32 | + }, | ||
33 | + 'jasmine-html':{ | ||
34 | + deps:['jasmine'], | ||
35 | + exports: 'jasmine' | ||
36 | + }, | ||
37 | + 'jasmine-boot':{ | ||
38 | + deps:['jasmine-html','jasmine'], | ||
39 | + exports:'jasmine' | ||
40 | + } | ||
41 | + } | ||
42 | + }; | ||
27 | 43 | ||
28 | </script> | 44 | </script> |
29 | 45 | ||
30 | - <script src="../js/require.js" data-main="../js/requirejs-config.js" ></script> | 46 | + <script src="../js/require.js"></script> |
47 | + | ||
31 | <!-- // <script src="../js/handlebars-v3.0.1.js"></script> --> | 48 | <!-- // <script src="../js/handlebars-v3.0.1.js"></script> --> |
32 | <!-- // <script src="../js/handlebars-helpers.js"></script> --> | 49 | <!-- // <script src="../js/handlebars-helpers.js"></script> --> |
33 | 50 | ||
@@ -43,18 +60,36 @@ | @@ -43,18 +60,36 @@ | ||
43 | "domReady!", | 60 | "domReady!", |
44 | "spec/MainSpec" | 61 | "spec/MainSpec" |
45 | ], | 62 | ], |
46 | - function( document ){ | 63 | + function( jasmine ){ |
64 | + | ||
65 | + // window.jasmine = jasmineRequire.core(jasmineRequire); | ||
66 | + // | ||
67 | + // jasmineRequire.html(jasmine); | ||
68 | + // | ||
69 | + // var jasmineEnv = jasmine.getEnv(); | ||
70 | + // jasmineEnv.updateInterval = 1000; | ||
71 | + // | ||
72 | + // var htmlReporter = new jasmine.HtmlReporter(); | ||
73 | + // | ||
74 | + // jasmineEnv.addReporter(htmlReporter); | ||
75 | + // | ||
76 | + // jasmineEnv.specFilter = function (spec) { | ||
77 | + // return htmlReporter.specFilter(spec); | ||
78 | + // }; | ||
79 | + | ||
47 | 80 | ||
48 | // Set up the HTML reporter - this is reponsible for | 81 | // Set up the HTML reporter - this is reponsible for |
49 | // aggregating the results reported by Jasmine as the | 82 | // aggregating the results reported by Jasmine as the |
50 | // tests and suites are executed. | 83 | // tests and suites are executed. |
51 | - jasmine.getEnv().addReporter( | ||
52 | - new jasmine.HtmlReporter() | ||
53 | - ); | ||
54 | - | ||
55 | - // Run all the loaded test specs. | ||
56 | - jasmine.getEnv().execute(); | ||
57 | - | 84 | + // jasmine.getEnv().addReporter( |
85 | + // new jasmine.HtmlReporter() | ||
86 | + // ); | ||
87 | + // | ||
88 | + // // Run all the loaded test specs. | ||
89 | + // jasmine.getEnv().execute(); | ||
90 | + if(typeof window.onload == 'function'){ | ||
91 | + window.onload(); | ||
92 | + } | ||
58 | } | 93 | } |
59 | ); | 94 | ); |
60 | 95 |
test/spec/MainSpec.js
1 | -define(["model/main"],function(Main){ | 1 | +define(['jasmine-boot', 'model/proposal-app'],function(jasmine, ProposalApp){ |
2 | 2 | ||
3 | - describe("addVotedProposal", function(){ | ||
4 | - it("Should register a voted id", function(){ | ||
5 | - expect(Main.addVotedProposal(1)).toContain(1); | 3 | + describe("Limit proposal voting to one per browser", function(){ |
4 | + it("Should register a proposal id", function(){ | ||
5 | + expect(ProposalApp.addVotedProposal(99)).toContain(99); | ||
6 | + }); | ||
6 | 7 | ||
8 | + it("Should find a voted proposal", function(){ | ||
9 | + ProposalApp.addVotedProposal(3); | ||
10 | + expect(ProposalApp.hasProposalbeenVoted(3)).toBe(true); | ||
7 | }); | 11 | }); |
12 | + | ||
8 | }); | 13 | }); |
14 | + | ||
15 | + | ||
9 | }); | 16 | }); |