-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathPlatformReporterTests.js
More file actions
93 lines (83 loc) · 2.66 KB
/
PlatformReporterTests.js
File metadata and controls
93 lines (83 loc) · 2.66 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* GPII Web-based PlatformReporter unit tests/
*
* Copyright 2017 Inclusive Design Research Centre, OCAD University
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License. You may obtain a copy of the License at
* https://github.com/gpii/universal/LICENSE.txt
*/
/* global require */
"use strict";
var fluid = require("infusion"),
jqUnit = fluid.require("node-jqunit");
require("../index.js");
var gpii = fluid.registerNamespace("gpii");
fluid.registerNamespace("gpii.tests.platformReporter");
fluid.defaults("gpii.tests.platformReporter", {
gradeNames: ["gpii.platformReporter", "gpii.contexts.test"],
invokers: {
reportPlatform: {
funcName: "gpii.tests.platformReporter.reportAll",
args: ["{that}"]
}
}
});
// Mock OS info, e.g., screen resolutions.
gpii.tests.platformReporter.OSinfo = fluid.freezeRecursive({
"screen-resolution": { width: 640, height: 480 },
"available-resolutions": [
{ width: 640, height: 480 },
{ width: 1440, height: 900 },
{ width: 1680, height: 1050 }
]
});
/**
* Return a mock of screen resolutions.
*
* @param {Component} that - A platform reporter instance.
* @return {Object} - Basic OS + current and available screen resolutions.
*/
gpii.tests.platformReporter.reportAll = function (that) {
var allInfo = that.getBasicOS();
return Object.assign(allInfo, gpii.tests.platformReporter.OSinfo);
};
var platformReporter = gpii.tests.platformReporter();
jqUnit.module("Platform Reporter");
jqUnit.test(
"Test getBasicOS()",
function () {
var basicOS = platformReporter.getBasicOS();
jqUnit.assertDeepEq(
"Basic OS informaiton", 2, Object.keys(basicOS).length
);
jqUnit.assertNotNull("ID property", basicOS.id);
jqUnit.assertNotNull("Version property", basicOS.version);
}
);
jqUnit.test(
"Test reportPlatform()",
function () {
var platform = platformReporter.reportPlatform();
jqUnit.assertEquals(
"OS ID",
platformReporter.getBasicOS().id,
platform.id
);
jqUnit.assertEquals(
"OS Version",
platformReporter.getBasicOS().version,
platform.version
);
jqUnit.assertDeepEq(
"Screen resolution",
gpii.tests.platformReporter.OSinfo["screen-resolution"],
platform["screen-resolution"]
);
jqUnit.assertDeepEq(
"Available resolutions",
gpii.tests.platformReporter.OSinfo["available-resolutions"],
platform["available-resolutions"]
);
}
);