OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 let mojoPrivate = require('mojoPrivate').binding; | 7 let mojoPrivate = require('mojoPrivate').binding; |
8 let test = require('test').binding; | 8 let test = require('test').binding; |
9 let unittestBindings = require('test_environment_specific_bindings'); | 9 let unittestBindings = require('test_environment_specific_bindings'); |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 })); | 24 })); |
25 mojoPrivate.define('dependency', test.callbackPass(function() { | 25 mojoPrivate.define('dependency', test.callbackPass(function() { |
26 return {result: 12345}; | 26 return {result: 12345}; |
27 })); | 27 })); |
28 }, | 28 }, |
29 | 29 |
30 function testDefineModuleDoesNotExist() { | 30 function testDefineModuleDoesNotExist() { |
31 mojoPrivate.define('testModule', ['does not exist!'], test.fail); | 31 mojoPrivate.define('testModule', ['does not exist!'], test.fail); |
32 test.succeed(); | 32 test.succeed(); |
33 }, | 33 }, |
| 34 |
| 35 function testRequireAsync() { |
| 36 console.log('requireAsync'); |
| 37 mojoPrivate.requireAsync('mojo/public/js/codec').then( |
| 38 test.callbackPass(function(codec) { |
| 39 test.assertEq('function', typeof codec.Message); |
| 40 })); |
| 41 }, |
| 42 |
| 43 function testRequireAsyncModuleDoesNotExist() { |
| 44 console.log('requireAsync'); |
| 45 mojoPrivate.requireAsync('testModule').then( |
| 46 test.fail, |
| 47 test.succeed); |
| 48 }, |
| 49 |
| 50 function testDefineAndRequire() { |
| 51 mojoPrivate.define('testModule', ['dependency'], |
| 52 test.callbackPass(function(module) { |
| 53 test.assertEq(12345, module.result); |
| 54 mojoPrivate.requireAsync('dependency').then( |
| 55 test.succeed, |
| 56 test.fail); |
| 57 mojoPrivate.requireAsync('NOT_A_MODULE').then( |
| 58 test.fail, |
| 59 test.succeed); |
| 60 })); |
| 61 mojoPrivate.define('dependency', test.callbackPass(function() { |
| 62 return {result: 12345}; |
| 63 })); |
| 64 } |
34 ], test.runTests, exports); | 65 ], test.runTests, exports); |
OLD | NEW |