@builder.io/react 2.0.11 → 2.0.12

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.
@@ -1076,7 +1076,7 @@ export class BuilderComponent extends React.Component<
1076
1076
  block.id?.startsWith('builder-pixel')
1077
1077
  );
1078
1078
 
1079
- if (data && !hasPixel) {
1079
+ if (data && !hasPixel && blocks.length > 0) {
1080
1080
  blocks.push(getBuilderPixel(builder.apiKey!));
1081
1081
  }
1082
1082
 
@@ -40,7 +40,7 @@ const sizes = {
40
40
  };
41
41
  export type Sizes = typeof sizes;
42
42
 
43
- interface Breakpoints {
43
+ export interface Breakpoints {
44
44
  small?: number;
45
45
  medium?: number;
46
46
  }
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Builder Pixel Should be added automatically if missing in blocks array 1`] = `
3
+ exports[`Builder Pixel Should NOT be added if missing in blocksString 1`] = `
4
4
  <div
5
5
  className="builder-component builder-component-id"
6
6
  data-name="page"
@@ -21,24 +21,15 @@ exports[`Builder Pixel Should be added automatically if missing in blocks array
21
21
 
22
22
  <div
23
23
  builder-type="blocks"
24
- className="builder-blocks css-h47494"
24
+ className="builder-blocks no-blocks css-h47494"
25
25
  onClick={[Function]}
26
- >
27
- <img
28
- aria-hidden="true"
29
- builder-id="builder-pixel-4fzzzxjylrx"
30
- className="builder-block builder-pixel-4fzzzxjylrx css-1mvsfya"
31
- role="presentation"
32
- src="https://cdn.builder.io/api/v1/pixel?apiKey=null"
33
- style={Object {}}
34
- />
35
- </div>
26
+ />
36
27
  </div>
37
28
  </div>
38
29
  </div>
39
30
  `;
40
31
 
41
- exports[`Builder Pixel Should be added automatically if missing in blocksString 1`] = `
32
+ exports[`Builder Pixel Should NOT be added again if already present in blocks array 1`] = `
42
33
  <div
43
34
  className="builder-component builder-component-id"
44
35
  data-name="page"
@@ -76,7 +67,36 @@ exports[`Builder Pixel Should be added automatically if missing in blocksString
76
67
  </div>
77
68
  `;
78
69
 
79
- exports[`Builder Pixel Should not be added if already present in blocks array 1`] = `
70
+ exports[`Builder Pixel Should NOT be added if missing in blocks array 1`] = `
71
+ <div
72
+ className="builder-component builder-component-id"
73
+ data-name="page"
74
+ data-source="Rendered by Builder.io"
75
+ onClick={[Function]}
76
+ >
77
+ <div
78
+ builder-content-id="id"
79
+ builder-model="page"
80
+ className="builder-content"
81
+ onClick={[Function]}
82
+ >
83
+ <div
84
+ data-builder-component="page"
85
+ data-builder-content-id="id"
86
+ data-builder-variation-id="id"
87
+ >
88
+
89
+ <div
90
+ builder-type="blocks"
91
+ className="builder-blocks no-blocks css-h47494"
92
+ onClick={[Function]}
93
+ />
94
+ </div>
95
+ </div>
96
+ </div>
97
+ `;
98
+
99
+ exports[`Builder Pixel Should be added if pixel is missing and blocks array has other block(s) 1`] = `
80
100
  <div
81
101
  className="builder-component builder-component-id"
82
102
  data-name="page"
@@ -100,6 +120,24 @@ exports[`Builder Pixel Should not be added if already present in blocks array 1`
100
120
  className="builder-blocks css-h47494"
101
121
  onClick={[Function]}
102
122
  >
123
+ <div
124
+ builder-id="builder-270035a08d734ae88ea177daff3595c0"
125
+ className="builder-block builder-270035a08d734ae88ea177daff3595c0 builder-has-component css-hgfgng"
126
+ style={Object {}}
127
+ >
128
+ <span
129
+ className="builder-text css-1qggkls"
130
+ dangerouslySetInnerHTML={
131
+ Object {
132
+ "__html": "<p>some text...</p>",
133
+ }
134
+ }
135
+ onBlur={[Function]}
136
+ onFocus={[Function]}
137
+ onInput={[Function]}
138
+ onKeyDown={[Function]}
139
+ />
140
+ </div>
103
141
  <img
104
142
  aria-hidden="true"
105
143
  builder-id="builder-pixel-4fzzzxjylrx"
@@ -184,7 +184,7 @@ describe('Content changes when new content provided', () => {
184
184
  });
185
185
 
186
186
  describe('Builder Pixel', () => {
187
- it('Should be added automatically if missing in blocksString', () => {
187
+ it('Should NOT be added if missing in blocksString', () => {
188
188
  const renderedBlock = reactTestRenderer.create(
189
189
  <BuilderPage
190
190
  model="page"
@@ -199,7 +199,7 @@ describe('Builder Pixel', () => {
199
199
  expect(renderedBlock).toMatchSnapshot();
200
200
  });
201
201
 
202
- it('Should be added automatically if missing in blocks array', () => {
202
+ it('Should NOT be added if missing in blocks array', () => {
203
203
  const renderedBlock = reactTestRenderer.create(
204
204
  <BuilderPage
205
205
  model="page"
@@ -215,7 +215,7 @@ describe('Builder Pixel', () => {
215
215
  expect(renderedBlock).toMatchSnapshot();
216
216
  });
217
217
 
218
- it('Should not be added if already present in blocks array', () => {
218
+ it('Should NOT be added again if already present in blocks array', () => {
219
219
  const renderedBlock = reactTestRenderer.create(
220
220
  <BuilderPage
221
221
  model="page"
@@ -230,4 +230,44 @@ describe('Builder Pixel', () => {
230
230
 
231
231
  expect(renderedBlock).toMatchSnapshot();
232
232
  });
233
+
234
+ it('Should be added if pixel is missing and blocks array has other block(s)', () => {
235
+ const renderedBlock = reactTestRenderer.create(
236
+ <BuilderPage
237
+ model="page"
238
+ content={{
239
+ id: 'id',
240
+ data: {
241
+ blocks: [
242
+ {
243
+ '@type': '@builder.io/sdk:Element',
244
+ '@version': 2,
245
+ id: 'builder-270035a08d734ae88ea177daff3595c0',
246
+ component: {
247
+ name: 'Text',
248
+ options: {
249
+ text: '<p>some text...</p>',
250
+ },
251
+ },
252
+ responsiveStyles: {
253
+ large: {
254
+ display: 'flex',
255
+ flexDirection: 'column',
256
+ position: 'relative',
257
+ flexShrink: '0',
258
+ boxSizing: 'border-box',
259
+ marginTop: '20px',
260
+ lineHeight: 'normal',
261
+ height: 'auto',
262
+ },
263
+ },
264
+ },
265
+ ],
266
+ },
267
+ }}
268
+ />
269
+ );
270
+
271
+ expect(renderedBlock).toMatchSnapshot();
272
+ });
233
273
  });