Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions test/src/tests-feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const hasIdentifyReturned = () => {
return window.mParticle.Identity.getCurrentUser()?.getMPID() === testMPID;
};

describe('feature-flags', function() {
describe('user audiences', function() {
beforeEach(function() {
describe('feature-flags', () => {
describe('user audiences', () => {
beforeEach(() => {
fetchMock.post(urls.events, 200);

fetchMockSuccess(urls.identify, {
Expand All @@ -38,7 +38,7 @@ describe('feature-flags', function() {
fetchMock.restore();
});

it('should not be able to access user audience API if feature flag is false', function() {
it('should not be able to access user audience API if feature flag is false', async () => {
window.mParticle.config.flags = {
audienceAPI: 'False'
};
Expand All @@ -47,19 +47,18 @@ describe('feature-flags', function() {

// initialize mParticle with feature flag
window.mParticle.init(apiKey, window.mParticle.config);
waitForCondition(hasIdentifyReturned)
.then(() => {
await waitForCondition(hasIdentifyReturned);

const bond = sinon.spy(window.mParticle.getInstance().Logger, 'error');
window.mParticle.Identity.getCurrentUser().getUserAudiences();

bond.called.should.eql(true);
bond.getCalls()[0].args[0].should.eql(
Constants.Messages.ErrorMessages.AudienceAPINotEnabled
);
})
});

it('should be able to call user audience API if feature flag is false', function() {
it('should be able to call user audience API if feature flag is false', async () => {
const userAudienceUrl = `https://${Constants.DefaultBaseUrls.userAudienceUrl}${apiKey}/audience`;
const audienceMembershipServerResponse = {
ct: 1710441407915,
Expand Down Expand Up @@ -88,15 +87,14 @@ describe('feature-flags', function() {

// initialize mParticle with feature flag
window.mParticle.init(apiKey, window.mParticle.config);
waitForCondition(hasIdentifyReturned)
.then(() => {
await waitForCondition(hasIdentifyReturned);

const bond = sinon.spy(window.mParticle.getInstance().Logger, 'error');

window.mParticle.Identity.getCurrentUser().getUserAudiences((result) => {
console.log(result);
});
bond.called.should.eql(false);
})
});
});

Expand Down
Loading