| <!doctype html> |
| <html> |
| <head> |
| <title>Budget API: Make basic getCost calls.</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="/js-test-resources/mojo-helpers.js"></script> |
| <script src="budget-service-mock.js"></script> |
| </head> |
| <body> |
| <script> |
| if (!window.mojo) |
| debug('This test can not run without mojo'); |
| |
| promise_test(function() { |
| return budgetServiceMock.then(mock => { |
| assert_own_property(Navigator.prototype, 'budget'); |
| return navigator.budget.getCost("silent-push"); |
| }).then(cost => { |
| assert_equals(cost, TEST_BUDGET_COST); |
| }); |
| }, 'BudgetService.GetCost should return correct results.'); |
| |
| promise_test(function() { |
| return budgetServiceMock.then(mock => { |
| assert_own_property(Navigator.prototype, 'budget'); |
| return navigator.budget.getCost("frobinator"); |
| }).then(cost => { |
| assert_unreached('getCost should have failed with an invalid argument.'); |
| }, function(error) { |
| assert_equals(error.name, 'TypeError'); |
| assert_equals(error.message, "Failed to execute 'getCost' on 'BudgetService': The provided value 'frobinator' is not a valid enum value of type ActionType."); |
| }); |
| }, 'BudgetService.GetCost should return Type Error if an invalid argument is provided.'); |
| </script> |
| </body> |
| </html> |