xref: /expo/apps/test-suite/tests/SystemUI.js (revision c6f6c7d6)
1import * as SystemUI from 'expo-system-ui';
2
3export const name = 'SystemUI';
4
5export async function test(t) {
6  async function flipValueAsync({ getAsync, setAsync, values }) {
7    // Set initial value to adjust for any state.
8    await setAsync(values[0]);
9
10    // Get the newly set value.
11    const value = await getAsync();
12    t.expect(value).toBeDefined();
13    t.expect(value.toUpperCase()).toBe(values[0]);
14
15    // Toggle value again and ensure it's different.
16    const nextValue = value === values[0] ? values[1] : values[0];
17    await setAsync(nextValue);
18    const mutated = await getAsync();
19    t.expect(mutated.toUpperCase()).toBe(nextValue);
20  }
21  t.describe(`SystemUI.setBackgroundColorAsync()`, () => {
22    t.it(`flips a value`, async () => {
23      await flipValueAsync({
24        getAsync: SystemUI.getBackgroundColorAsync,
25        setAsync: SystemUI.setBackgroundColorAsync,
26        values: ['#FF0000', '#FFFFFF'],
27      });
28    });
29  });
30}
31