- Allow scheduled operations to resolve multiple device groups. - Add reusable SMS time and random-value macros. - Add China operator PLMN metadata shared by API and UI.
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { lookupOperator, operatorLabel } from './operators.js';
|
|
|
|
describe('lookupOperator', () => {
|
|
it('resolves an assigned mainland PLMN', () => {
|
|
expect(lookupOperator('460', '00')?.name).toBe('中国移动');
|
|
expect(lookupOperator(460, 1)?.name).toBe('中国联通');
|
|
expect(lookupOperator('460', '15')?.name).toBe('中国广电');
|
|
expect(lookupOperator('460', '20')?.name).toBe('中国铁通');
|
|
});
|
|
|
|
it('pads a single-digit MNC the way the network reports it', () => {
|
|
expect(lookupOperator('460', '3')?.name).toBe('中国电信');
|
|
});
|
|
|
|
it('leaves foreign and unassigned codes unresolved', () => {
|
|
expect(lookupOperator('262', '01')).toBeNull();
|
|
expect(lookupOperator('460', '77')).toBeNull();
|
|
expect(lookupOperator(undefined, '01')).toBeNull();
|
|
expect(lookupOperator('', '')).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('operatorLabel', () => {
|
|
it('prefers the registry over the string the device reported', () => {
|
|
expect(operatorLabel({ mcc: '460', mnc: '00', operator: 'CHN-CMCC' })).toBe('中国移动');
|
|
});
|
|
|
|
it('falls back to the reported name, then the bare PLMN, then the caller default', () => {
|
|
expect(operatorLabel({ mcc: '262', mnc: '01', operator: 'Telekom' })).toBe('Telekom');
|
|
expect(operatorLabel({ mcc: '262', mnc: '01' })).toBe('262-01');
|
|
expect(operatorLabel({})).toBe('未知运营商');
|
|
expect(operatorLabel({ operator: ' ' })).toBe('未知运营商');
|
|
});
|
|
|
|
it('accepts a custom fallback for a table cell', () => {
|
|
expect(operatorLabel({ fallback: '运营商未知' })).toBe('运营商未知');
|
|
});
|
|
});
|