|
12 | 12 | import { describe, it } from 'node:test';
|
13 | 13 | import assert from 'node:assert/strict';
|
14 | 14 | import { readFileSync } from 'node:fs';
|
15 |
| -import { facets } from '../facets.js'; |
| 15 | +import { facets, facetFns } from '../facets.js'; |
16 | 16 | import { DataChunks } from '../distiller.js';
|
17 | 17 | import { pageViews } from '../series.js';
|
18 | 18 |
|
@@ -180,3 +180,45 @@ describe('facets:mediaTarget', () => {
|
180 | 180 | assert.equal(d.facets.mediaTarget[0].value, '/media_1645e7a92e9f8448d45e8b999afa71315cc52690b.png');
|
181 | 181 | });
|
182 | 182 | });
|
| 183 | + |
| 184 | +describe('facets:checkpointSource', () => { |
| 185 | + it('checkpointSource:bare', () => { |
| 186 | + assert.deepEqual( |
| 187 | + facetFns.checkpointSource('enter')({ |
| 188 | + events: [{ checkpoint: 'enter', source: 'https://www.example.com' }], |
| 189 | + }), |
| 190 | + ['https://www.example.com'], |
| 191 | + ); |
| 192 | + }); |
| 193 | + |
| 194 | + it('checkpointSource:DataChunks', () => { |
| 195 | + const d = new DataChunks(); |
| 196 | + d.load(testChunks); |
| 197 | + d.addSeries('pageViews', pageViews); |
| 198 | + d.addFacet('checkpointSource', facetFns.checkpointSource('enter')); |
| 199 | + |
| 200 | + assert.equal(d.facets.checkpointSource.length, 28); |
| 201 | + assert.equal(d.facets.checkpointSource[0].value, '(direct)'); |
| 202 | + }); |
| 203 | +}); |
| 204 | + |
| 205 | +describe('facets:checkpointTarget', () => { |
| 206 | + it('checkpointTarget:bare', () => { |
| 207 | + assert.deepEqual( |
| 208 | + facetFns.checkpointTarget('click')({ |
| 209 | + events: [{ checkpoint: 'click', target: 'https://www.example.com' }], |
| 210 | + }), |
| 211 | + ['https://www.example.com'], |
| 212 | + ); |
| 213 | + }); |
| 214 | + |
| 215 | + it('checkpointTarget:DataChunks', () => { |
| 216 | + const d = new DataChunks(); |
| 217 | + d.load(testChunks); |
| 218 | + d.addSeries('pageViews', pageViews); |
| 219 | + d.addFacet('checkpointTarget', facetFns.checkpointTarget('click')); |
| 220 | + |
| 221 | + assert.equal(d.facets.checkpointTarget.length, 116); |
| 222 | + assert.equal(d.facets.checkpointTarget[0].value, 'https://www.aem.live/developer/block-collection'); |
| 223 | + }); |
| 224 | +}); |
0 commit comments