|
8 | 8 | setReadOnly, |
9 | 9 | setSenseHatAlwaysEnabled, |
10 | 10 | setReactAppApiEndpoint, |
| 11 | + setScratchApiEndpoint, |
11 | 12 | } from "../redux/EditorSlice"; |
12 | 13 | import { setInstructions } from "../redux/InstructionsSlice"; |
13 | 14 | import { setUser } from "../redux/WebComponentAuthSlice"; |
@@ -108,6 +109,45 @@ describe("When initially rendered", () => { |
108 | 109 | expect(mockedChangeLanguage).toHaveBeenCalledWith("es-LA"); |
109 | 110 | }); |
110 | 111 |
|
| 112 | + describe("scratch API endpoint", () => { |
| 113 | + describe("when scratch API endpoint isn't set", () => { |
| 114 | + beforeEach(() => { |
| 115 | + render( |
| 116 | + <Provider store={store}> |
| 117 | + <WebComponentLoader /> |
| 118 | + </Provider>, |
| 119 | + ); |
| 120 | + }); |
| 121 | + |
| 122 | + test("it defaults to env", () => { |
| 123 | + expect(store.getActions()).toEqual( |
| 124 | + expect.arrayContaining([ |
| 125 | + setScratchApiEndpoint("http://localhost:3009"), |
| 126 | + ]), |
| 127 | + ); |
| 128 | + }); |
| 129 | + }); |
| 130 | + |
| 131 | + describe("when scratch API endpoint is set", () => { |
| 132 | + beforeEach(() => { |
| 133 | + render( |
| 134 | + <Provider store={store}> |
| 135 | + <WebComponentLoader |
| 136 | + scratchApiEndpoint="http://local.dev" |
| 137 | + theme="light" |
| 138 | + /> |
| 139 | + </Provider>, |
| 140 | + ); |
| 141 | + }); |
| 142 | + |
| 143 | + test("it uses the specified prop", () => { |
| 144 | + expect(store.getActions()).toEqual( |
| 145 | + expect.arrayContaining([setScratchApiEndpoint("http://local.dev")]), |
| 146 | + ); |
| 147 | + }); |
| 148 | + }); |
| 149 | + }); |
| 150 | + |
111 | 151 | describe("react app API endpoint", () => { |
112 | 152 | describe("when react app API endpoint isn't set", () => { |
113 | 153 | beforeEach(() => { |
|
0 commit comments