This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
/
operatorVariant_test.js
87 lines (75 loc) · 2.19 KB
/
operatorVariant_test.js
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
'use strict';
requireApp('communications/shared/test/unit/mocks/mock_icc_helper.js');
requireApp('communications/ftu/test/unit/mock_navigator_moz_settings.js');
requireApp('communications/ftu/js/operatorVariant.js');
var mocksHelper = new MocksHelper([
'IccHelper'
]).init();
suite('operatorVariant set First run state >', function() {
const KEY_SIM_ON_1ST_RUN = 'ftu.simPresentOnFirstBoot';
var SAVE_STATE_WAIT_TIMEOUT = 200;
var realSettings;
suiteSetup(function() {
mocksHelper.suiteSetup();
realSettings = navigator.mozSettings;
navigator.mozSettings = MockNavigatorSettings;
});
suiteTeardown(function() {
mocksHelper.suiteTeardown();
navigator.mozSettings = realSettings;
realSettings = null;
});
// helper to change single key-value of mozSettings
function changeSettings(key, value) {
var cset = {};
cset[key] = value;
MockNavigatorSettings.createLock().set(cset);
}
setup(function() {
mocksHelper.setup();
});
var testCases = [
{
'preValSet': undefined,
'expecValSet': false,
'cardState': 'unknown',
'title': 'Operator Variant set first run type - unkown sim'
},
{
'preValSet': undefined,
'expecValSet': true,
'cardState': 'ready',
'title': 'Operator Variant set first run type - sim ready'
},
{
'preValSet': undefined,
'expecValSet': false,
'cardState': 'pinRequired',
'title': 'Operator Variant set first run type - sim pinRequired'
},
{
'preValSet': true,
'expecValSet': true,
'cardState': 'ready',
'title': 'Operator Variant first run type previously set true'
},
{
'preValSet': false,
'expecValSet': false,
'cardState': 'ready',
'title': 'Operator Variant set first run type previously set false'
}
];
testCases.forEach((function(testCase) {
test(testCase.title, function(done) {
MockIccHelper.mProps['cardState'] = testCase.cardState;
changeSettings(KEY_SIM_ON_1ST_RUN, testCase.preValSet);
OperatorVariant.setSIMOnFirstBootState();
setTimeout(function() {
var mSettings = MockNavigatorSettings.mSettings;
assert.equal(mSettings[KEY_SIM_ON_1ST_RUN], testCase.expecValSet);
done();
}, SAVE_STATE_WAIT_TIMEOUT);
});
}));
});