xref: /expo/apps/test-suite/tests/KeepAwake.js (revision b41269b4)
1import * as KeepAwake from 'expo-keep-awake';
2
3export const name = 'KeepAwake';
4
5export async function test(
6  { it, describe, beforeAll, jasmine, afterAll, expect, afterEach, beforeEach },
7  { setPortalChild, cleanupPortal }
8) {
9  describe(name, () => {
10    afterAll(async () => {
11      if (await KeepAwake.isAvailableAsync()) {
12        await KeepAwake.deactivateKeepAwake();
13        await KeepAwake.deactivateKeepAwake('test-tag');
14      }
15    });
16
17    it(`keeps the screen on`, async () => {
18      if (await KeepAwake.isAvailableAsync()) {
19        await KeepAwake.activateKeepAwakeAsync();
20      }
21    });
22    it(`keeps the screen on with a tag`, async () => {
23      if (await KeepAwake.isAvailableAsync()) {
24        await KeepAwake.activateKeepAwakeAsync('test-tag');
25      }
26    });
27    it(`enables screen timeout`, async () => {
28      if (await KeepAwake.isAvailableAsync()) {
29        await KeepAwake.deactivateKeepAwake();
30      }
31    });
32    it(`enables screen timeout with a tag`, async () => {
33      if (await KeepAwake.isAvailableAsync()) {
34        await KeepAwake.deactivateKeepAwake('test-tag');
35      }
36    });
37  });
38}
39