sku-pg
Version:
Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!
102 lines (89 loc) • 2.85 kB
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.LoggerServer</title>
<script src="../base.js"></script>
<script>
goog.require('goog.log');
goog.require('goog.log.Level');
goog.require('goog.messaging.LoggerServer');
goog.require('goog.testing.MockControl');
goog.require('goog.testing.PropertyReplacer');
goog.require('goog.testing.jsunit');
goog.require('goog.testing.messaging.MockMessageChannel');
</script>
</head>
<body>
<script>
var mockControl;
var channel;
var stubs = new goog.testing.PropertyReplacer();
function setUp() {
mockControl = new goog.testing.MockControl();
channel = new goog.testing.messaging.MockMessageChannel(mockControl);
stubs.set(goog.debug.Logger, 'getLogger',
mockControl.createFunctionMock('goog.log.getLogger'));
}
function tearDown() {
channel.dispose();
stubs.reset();
}
function testCommandWithoutChannelName() {
var mockLogger = mockControl.createStrictMock(goog.debug.Logger);
goog.log.getLogger('test.object.Name').$returns(mockLogger);
goog.log.log(mockLogger,
goog.log.Level.SEVERE, '[remote logger] foo bar', null);
mockControl.$replayAll();
var server = new goog.messaging.LoggerServer(channel, 'log');
channel.receive('log', {
name: 'test.object.Name',
level: goog.log.Level.SEVERE.value,
message: 'foo bar',
exception: null
});
mockControl.$verifyAll();
server.dispose();
}
function testCommandWithChannelName() {
var mockLogger = mockControl.createStrictMock(goog.debug.Logger);
goog.log.getLogger('test.object.Name').$returns(mockLogger);
goog.log.log(mockLogger,
goog.log.Level.SEVERE, '[some channel] foo bar', null);
mockControl.$replayAll();
var server = new goog.messaging.LoggerServer(channel, 'log', 'some channel');
channel.receive('log', {
name: 'test.object.Name',
level: goog.log.Level.SEVERE.value,
message: 'foo bar',
exception: null
});
mockControl.$verifyAll();
server.dispose();
}
function testCommandWithException() {
var mockLogger = mockControl.createStrictMock(goog.debug.Logger);
goog.log.getLogger('test.object.Name').$returns(mockLogger);
goog.log.log(mockLogger,
goog.log.Level.SEVERE, '[some channel] foo bar',
{message: 'Bad things', stack: ['foo', 'bar']});
mockControl.$replayAll();
var server = new goog.messaging.LoggerServer(channel, 'log', 'some channel');
channel.receive('log', {
name: 'test.object.Name',
level: goog.log.Level.SEVERE.value,
message: 'foo bar',
exception: {message: 'Bad things', stack: ['foo', 'bar']}
});
mockControl.$verifyAll();
server.dispose();
}
</script>
</body>
</html>