@builder.io/react 2.0.11-3 → 2.0.11-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,8 @@ import { render } from '@testing-library/react';
8
8
  import { Builder, builder } from '@builder.io/sdk';
9
9
  import { BuilderPage } from '../src/builder-react';
10
10
  import { el, block } from './functions/render-block';
11
+ import * as reactTestRenderer from 'react-test-renderer';
12
+ import { getBuilderPixel } from '../src/functions/get-builder-pixel';
11
13
 
12
14
  builder.init('null');
13
15
 
@@ -180,3 +182,52 @@ describe('Content changes when new content provided', () => {
180
182
  expect(testApi.getByText(textB)).toBeInTheDocument();
181
183
  });
182
184
  });
185
+
186
+ describe('Builder Pixel', () => {
187
+ it('Should be added automatically if missing in blocksString', () => {
188
+ const renderedBlock = reactTestRenderer.create(
189
+ <BuilderPage
190
+ model="page"
191
+ content={{
192
+ id: 'id',
193
+ data: {
194
+ blocksString: '[]',
195
+ },
196
+ }}
197
+ />
198
+ );
199
+ expect(renderedBlock).toMatchSnapshot();
200
+ });
201
+
202
+ it('Should be added automatically if missing in blocks array', () => {
203
+ const renderedBlock = reactTestRenderer.create(
204
+ <BuilderPage
205
+ model="page"
206
+ content={{
207
+ id: 'id',
208
+ data: {
209
+ blocks: [],
210
+ },
211
+ }}
212
+ />
213
+ );
214
+
215
+ expect(renderedBlock).toMatchSnapshot();
216
+ });
217
+
218
+ it('Should not be added if already present in blocks array', () => {
219
+ const renderedBlock = reactTestRenderer.create(
220
+ <BuilderPage
221
+ model="page"
222
+ content={{
223
+ id: 'id',
224
+ data: {
225
+ blocks: [getBuilderPixel('null')],
226
+ },
227
+ }}
228
+ />
229
+ );
230
+
231
+ expect(renderedBlock).toMatchSnapshot();
232
+ });
233
+ });
@@ -0,0 +1,6 @@
1
+ beforeEach(() => {
2
+ jest.spyOn(global.Math, 'random').mockReturnValue(0.123456789);
3
+ });
4
+ afterEach(() => {
5
+ jest.spyOn(global.Math, 'random').mockRestore();
6
+ });