VulpesOS/gaia/apps/sharedtest/test/unit/simslot_test.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

114 lines
3.1 KiB
JavaScript
Executable file

/* globals SIMSlot */
'use strict';
suite('SIMSlot', function() {
suiteSetup(function() {
});
suiteTeardown(function() {
});
setup(function(callback) {
require('/shared/js/simslot.js', callback);
});
teardown(function() {
});
test('new', function() {
var created = false;
window.addEventListener('simslot-created', function() {
created = true;
});
/*jshint unused: false */
var slot = new SIMSlot(null, 0);
assert.isTrue(created);
});
test('update', function() {
var slot = new SIMSlot(null, 0);
var card = document.createElement('div');
slot.update(card);
assert.deepEqual(slot.simCard, card);
});
test('isAbsent', function() {
var card = document.createElement('div');
card.iccInfo = {
iccid: 1
};
var slot1 = new SIMSlot(null, 0, card);
assert.isFalse(slot1.isAbsent());
var slot2 = new SIMSlot(null, 0);
assert.isTrue(slot2.isAbsent());
});
['permanentBlocked'].forEach(function(absentType) {
test('isAbsent: ' + absentType, function() {
var card = document.createElement('div');
card.cardState = absentType;
var slot = new SIMSlot(null, 0, card);
assert.isTrue(slot.isAbsent());
});
});
['unknown', 'illegal', 'absent', 'ready', null].forEach(function(lockType) {
test('isLocked: ' + lockType, function() {
var card = document.createElement('div');
card.cardState = lockType;
var slot = new SIMSlot(null, 0, card);
assert.isFalse(slot.isLocked());
});
});
['pinRequired', 'pukRequired', 'networkLocked',
'corporateLocked', 'serviceProviderLocked', 'network1Locked',
'network2Locked', 'hrpdNetworkLocked', 'ruimCorporateLocked',
'ruimServiceProviderLocked'].forEach(function(lockType) {
test('isLocked: ' + lockType, function() {
var card = document.createElement('div');
card.cardState = lockType;
var slot = new SIMSlot(null, 0, card);
assert.isTrue(slot.isLocked());
});
});
suite('handleEvent', function() {
test('cardstatechange', function() {
var slot = new SIMSlot(null, 0);
var stubPublish = this.sinon.stub(slot, 'publish');
slot.handleEvent({
type: 'cardstatechange'
});
assert.isTrue(stubPublish.calledWith('cardstatechange'));
});
test('iccinfochange', function() {
var slot = new SIMSlot(null, 0);
var stubPublish = this.sinon.stub(slot, 'publish');
slot.handleEvent({
type: 'iccinfochange'
});
assert.isTrue(stubPublish.calledWith('iccinfochange'));
});
test('stkcommand', function() {
var slot = new SIMSlot(null, 0);
var stubPublish = this.sinon.stub(slot, 'publish');
slot.handleEvent({
type: 'stkcommand'
});
assert.isTrue(stubPublish.calledWith('stkcommand'));
});
test('stksessionend', function() {
var slot = new SIMSlot(null, 0);
var stubPublish = this.sinon.stub(slot, 'publish');
slot.handleEvent({
type: 'stksessionend'
});
assert.isTrue(stubPublish.calledWith('stksessionend'));
});
});
});