aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/messaging/messaging_test.html
blob: 20af8c4a9c4bbe883b523ce6a3fd320451f4dff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<!--
Copyright 2010 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<!--
-->
<head>
<title>
  Closure Unit Tests - goog.messaging
</title>
<script src="../base.js"></script>
<script>
  goog.require('goog.messaging');
  goog.require('goog.testing.MockControl');
  goog.require('goog.testing.jsunit');
  goog.require('goog.testing.messaging.MockMessageChannel');
</script>
</head>
<body>
<script>

function testPipe() {
  var mockControl = new goog.testing.MockControl();
  var ch1 = new goog.testing.messaging.MockMessageChannel(mockControl);
  var ch2 = new goog.testing.messaging.MockMessageChannel(mockControl);
  ch1.send('ping', 'HELLO');
  ch2.send('pong', {key: 'value'});
  goog.messaging.pipe(ch1, ch2);

  mockControl.$replayAll();
  ch2.receive('ping', 'HELLO');
  ch1.receive('pong', {key: 'value'});
  mockControl.$verifyAll();
}

</script>
</body>
</html>