OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Budget API: Make basic getCost calls.</title> | 4 <title>Budget API: Make basic reserve calls.</title> |
5 <script src="../resources/testharness.js"></script> | 5 <script src="../resources/testharness.js"></script> |
6 <script src="../resources/testharnessreport.js"></script> | 6 <script src="../resources/testharnessreport.js"></script> |
7 <script src="/js-test-resources/mojo-helpers.js"></script> | 7 <script src="/js-test-resources/mojo-helpers.js"></script> |
8 <script src="budget-service-mock.js"></script> | 8 <script src="budget-service-mock.js"></script> |
9 </head> | 9 </head> |
10 <body> | 10 <body> |
11 <script> | 11 <script> |
12 if (!window.mojo) | 12 if (!window.mojo) |
13 debug('This test can not run without mojo'); | 13 debug('This test can not run without mojo'); |
14 | 14 |
15 promise_test(function() { | 15 promise_test(function() { |
16 return budgetServiceMock.then(mock => { | 16 return budgetServiceMock.then(mock => { |
17 assert_own_property(Navigator.prototype, 'budget'); | 17 assert_own_property(Navigator.prototype, 'budget'); |
18 return navigator.budget.getCost("silent-push"); | 18 mock.setReserveSuccess(true); |
19 }).then(cost => { | 19 return navigator.budget.reserve("silent-push"); |
20 assert_equals(cost, TEST_BUDGET_COST); | 20 }).then(success => { |
| 21 assert_equals(success, true); |
21 }); | 22 }); |
22 }, 'BudgetService.GetCost should return correct results.'); | 23 }, 'BudgetService.Reserve should return correct results.'); |
23 | 24 |
24 promise_test(function() { | 25 promise_test(function() { |
25 return budgetServiceMock.then(mock => { | 26 return budgetServiceMock.then(mock => { |
26 assert_own_property(Navigator.prototype, 'budget'); | 27 assert_own_property(Navigator.prototype, 'budget'); |
27 return navigator.budget.getCost("frobinator"); | 28 return navigator.budget.reserve("frobinator"); |
28 }).then(cost => { | 29 }).then(success => { |
29 assert_unreached('getCost should have failed with an invalid argument.
'); | 30 assert_unreached('reserve should have failed with an invalid argument.
'); |
30 }, function(error) { | 31 }, function(error) { |
31 assert_equals(error.name, 'TypeError'); | 32 assert_equals(error.name, 'TypeError'); |
32 assert_equals(error.message, "Failed to execute 'getCost' on 'BudgetSe
rvice': The provided value 'frobinator' is not a valid enum value of type Action
Type."); | 33 assert_equals(error.message, "Failed to execute 'reserve' on 'BudgetSe
rvice': The provided value 'frobinator' is not a valid enum value of type Operat
ionType."); |
33 }); | 34 }); |
34 }, 'BudgetService.GetCost should return Type Error if an invalid argument
is provided.'); | 35 }, 'BudgetService.Reserve should return Type Error if an invalid argument
is provided.'); |
35 </script> | 36 </script> |
36 </body> | 37 </body> |
37 </html> | 38 </html> |
OLD | NEW |