Skip to content

Commit bfcdb2b

Browse files
committed
test: move/rename test to persistence.products.spec
1 parent 0847f1e commit bfcdb2b

2 files changed

Lines changed: 34 additions & 34 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {
2+
mParticle,
3+
MPConfig,
4+
testMPID,
5+
} from '../src/config/constants';
6+
import { Product } from '@mparticle/web-sdk';
7+
8+
describe('Products Persistence', () => {
9+
let mpInstance = mParticle.getInstance();
10+
beforeEach(() => {
11+
mParticle._resetForTests(MPConfig);
12+
mpInstance._Persistence.resetPersistence();
13+
});
14+
15+
it('should save products to localStorage when noTargeting is false by default', () => {
16+
const product = { Name: 'iphone', Sku: 'iphonesku', Price: 599, Quantity: 1 };
17+
mpInstance._Persistence.setCartProducts({ [testMPID]: { cp: [product] } } as unknown as Product[]);
18+
expect(mpInstance._Persistence.getCartProducts(testMPID).length).toBe(1);
19+
});
20+
21+
it('should NOT save products to localStorage when noTargeting is true', () => {
22+
mpInstance._Store.setNoTargeting(true);
23+
const product = { Name: 'iphone', Sku: 'iphonesku', Price: 599, Quantity: 1 };
24+
mpInstance._Persistence.setCartProducts({ [testMPID]: { cp: [product] } } as unknown as Product[]);
25+
expect(mpInstance._Persistence.getCartProducts(testMPID).length).toBe(0);
26+
});
27+
28+
it('should save products to localStorage when noTargeting is false', () => {
29+
mpInstance._Store.setNoTargeting(false);
30+
const product = { Name: 'iphone', Sku: 'iphonesku', Price: 599, Quantity: 1 };
31+
mpInstance._Persistence.setCartProducts({ [testMPID]: { cp: [product] } } as unknown as Product[]);
32+
expect(mpInstance._Persistence.getCartProducts(testMPID).length).toBe(1);
33+
});
34+
});

test/jest/persistence.spec.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)