Debian Codegraph @

closure-library/closure/goog/useragent/jscript_test.js

raw
1 // Copyright 2006 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Mock JScript functions
16 goog.provide('goog.userAgent.jscriptTest');
17 goog.setTestOnly('goog.userAgent.jscriptTest');
18
19 goog.require('goog.testing.jsunit');
20 goog.require('goog.userAgent.jscript');
21
22 function ScriptEngine() {
23 return 'JScript';
24 }
25
26 function ScriptEngineMajorVersion() {
27 return 1;
28 }
29
30 function ScriptEngineMinorVersion() {
31 return 2;
32 }
33
34 function ScriptEngineBuildVersion() {
35 return 3456;
36 }
37
38 function setUpPage() {
39 goog.userAgent.jscript.init();
40 }
41
42 function testHasJscript() {
43 assertTrue('Should have jscript', goog.userAgent.jscript.HAS_JSCRIPT);
44 }
45
46 function testVersion() {
47 assertEquals(
48 'Version should be 1.2.3456', '1.2.3456', goog.userAgent.jscript.VERSION);
49 }
50
51 function testIsVersion() {
52 assertTrue(
53 'Should be version 1.2.3456 or larger',
54 goog.userAgent.jscript.isVersion('1.2.3456'));
55 assertTrue(
56 'Should be version 1.2 or larger',
57 goog.userAgent.jscript.isVersion('1.2'));
58 assertFalse(
59 'Should not be version 8.9 or larger',
60 goog.userAgent.jscript.isVersion('8.9'));
61 }