xref: /expo/apps/test-suite/tests/Cellular.js (revision 4543e9ae)
1import * as Cellular from 'expo-cellular';
2
3export const name = 'Cellular';
4
5export async function test({ describe, it, expect, jasmine }) {
6  describe('Cellular', () => {
7    describe('Cellular.allowsVoip', () => {
8      it('returns a boolean', () => {
9        const allowsVoip = Cellular.allowsVoip;
10
11        expect(allowsVoip).toEqual(jasmine.any(Boolean));
12      });
13    });
14    describe('Cellular.carrier', () => {
15      it('is defined', () => {
16        const carrier = Cellular.carrier;
17        // nullable
18        expect(carrier).toBeDefined();
19      });
20    });
21    describe('Cellular.isoCountryCode', () => {
22      it('is defined', () => {
23        const isoCountryCode = Cellular.isoCountryCode;
24        // nullable
25        expect(isoCountryCode).toBeDefined();
26      });
27    });
28    describe('Cellular.mobileCountryCode', () => {
29      it('is defined', () => {
30        const mobileCountryCode = Cellular.mobileCountryCode;
31        // nullable
32        expect(mobileCountryCode).toBeDefined();
33      });
34    });
35    describe('Cellular.mobileNetworkCode', () => {
36      it('is defined', () => {
37        const mobileNetworkCode = Cellular.mobileNetworkCode;
38        // nullable
39        expect(mobileNetworkCode).toBeDefined();
40      });
41    });
42
43    describe('Cellular.getCellularGenerationAsync()', () => {
44      it('returns an enum value of Cellular.Cellular Generation', async () => {
45        let hasError = false;
46        let cellularGeneration;
47        const CellularGenerationEnumValues = [0, 1, 2, 3, 4];
48
49        try {
50          cellularGeneration = await Cellular.getCellularGenerationAsync();
51        } catch (e) {
52          hasError = true;
53          console.log(e);
54        }
55
56        expect(hasError).toBe(false);
57        expect(cellularGeneration).toEqual(jasmine.any(Number));
58        expect(CellularGenerationEnumValues.includes(cellularGeneration)).toBe(true);
59      });
60    });
61  });
62
63  // TODO: What about if airplane mode is on?
64}
65