-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1140 from OneSignal/feat/getTags
[Feat] Add getTags to public API
- Loading branch information
Showing
6 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { TestEnvironment } from '../../support/environment/TestEnvironment'; | ||
import User from '../../../src/onesignal/User'; | ||
import { ModelName } from '../../../src/core/models/SupportedModels'; | ||
import { getDummyPropertyOSModel } from '../../support/helpers/core'; | ||
|
||
// suppress all internal logging | ||
jest.mock('../../../src/shared/libraries/Log'); | ||
|
||
describe('User tests', () => { | ||
test('getTags called without a properties model should return undefined tags', async () => { | ||
await TestEnvironment.initialize(); | ||
|
||
const user = User.createOrGetInstance(); | ||
const tags = user.getTags(); | ||
|
||
expect(tags).toBe(undefined); | ||
}); | ||
|
||
test('getTags called with undefined tags in properties model should return undefined tags', async () => { | ||
await TestEnvironment.initialize(); | ||
|
||
OneSignal.coreDirector.add(ModelName.Properties, getDummyPropertyOSModel()); | ||
|
||
const user = User.createOrGetInstance(); | ||
const tags = user.getTags(); | ||
|
||
expect(tags).toBe(undefined); | ||
}); | ||
|
||
test('getTags called with empty tags in properties model should return empty tags', async () => { | ||
await TestEnvironment.initialize(); | ||
|
||
const propertyModel = getDummyPropertyOSModel(); | ||
propertyModel.set('tags', {}); | ||
OneSignal.coreDirector.add(ModelName.Properties, propertyModel); | ||
|
||
const user = User.createOrGetInstance(); | ||
const tags = user.getTags(); | ||
|
||
expect(tags).toStrictEqual({}); | ||
}); | ||
|
||
test('getTags called with tags in properties model should return tags', async () => { | ||
await TestEnvironment.initialize(); | ||
|
||
const tagsSample = { key1: 'value1' }; | ||
|
||
const propertyModel = getDummyPropertyOSModel(); | ||
propertyModel.set('tags', tagsSample); | ||
OneSignal.coreDirector.add(ModelName.Properties, propertyModel); | ||
|
||
const user = User.createOrGetInstance(); | ||
const tags = user.getTags(); | ||
|
||
expect(tags).toBe(tagsSample); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters