-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
673 additions
and
431 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
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
56 changes: 56 additions & 0 deletions
56
test/cmds/variants-cmds/create-cmds/androidVariant.test.ts
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,56 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-ignore */ | ||
import {ConsoleMock} from '../../../mocks'; | ||
import { | ||
createApplication, | ||
getAllApplications, | ||
initMockEngine, | ||
} from '../../../mocks/UPSMock'; | ||
import {IDGenerator} from '../../../mocks/DataStore'; | ||
import {AndroidVariant} from '@aerogear/unifiedpush-admin-client'; | ||
import {handler} from '../../../../src/cmds/variants-cmds/create-cmds/andoridVariant'; | ||
|
||
beforeEach(() => { | ||
// Clear all instances and calls to constructor and all methods: | ||
initMockEngine(); | ||
createApplications(10); | ||
ConsoleMock.init(); | ||
ConsoleMock.mockClear(); | ||
}); | ||
|
||
afterEach(() => { | ||
ConsoleMock.uninstall(); | ||
}); | ||
|
||
const createApplications = (howmany: number) => { | ||
for (let i = 0; i < howmany; i++) { | ||
createApplication(`TEST APP-${i}`); | ||
} | ||
}; | ||
|
||
describe('variants create', () => { | ||
it('Should create an android variants', async () => { | ||
const app = getAllApplications()[3]; | ||
const variantDef = { | ||
name: 'TEST-ANDROID', | ||
type: 'android', | ||
googleKey: 'TEST-GOOGLE-KEY', | ||
projectNumber: 'TEST-PROJECT-NUMBER', | ||
} as AndroidVariant; | ||
|
||
const argv = { | ||
url: 'http://localhost:9999', | ||
appId: app.pushApplicationID, | ||
output: 'json', | ||
...variantDef, | ||
}; | ||
|
||
const variantID = IDGenerator.peek(); | ||
|
||
// @ts-ignore | ||
await handler(argv); | ||
expect(ConsoleMock.log).toHaveBeenCalledTimes(1); | ||
expect(JSON.parse(ConsoleMock.log.mock.calls[0][0])).toEqual([ | ||
app.variants?.find(v => v.variantID === variantID), | ||
]); | ||
}); | ||
}); |
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 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-ignore */ | ||
import {ConsoleMock} from '../../../mocks'; | ||
import { | ||
createApplication, | ||
getAllApplications, | ||
initMockEngine, | ||
} from '../../../mocks/UPSMock'; | ||
import {IDGenerator} from '../../../mocks/DataStore'; | ||
import {IOSVariantDefinition} from '@aerogear/unifiedpush-admin-client'; | ||
import {handler} from '../../../../src/cmds/variants-cmds/create-cmds/iosCert'; | ||
|
||
beforeEach(() => { | ||
// Clear all instances and calls to constructor and all methods: | ||
initMockEngine(); | ||
createApplications(10); | ||
ConsoleMock.init(); | ||
ConsoleMock.mockClear(); | ||
}); | ||
|
||
afterEach(() => { | ||
ConsoleMock.uninstall(); | ||
}); | ||
|
||
const createApplications = (howmany: number) => { | ||
for (let i = 0; i < howmany; i++) { | ||
createApplication(`TEST APP-${i}`); | ||
} | ||
}; | ||
|
||
describe('variants create', () => { | ||
it('Should create an ios variants', async () => { | ||
const app = getAllApplications()[3]; | ||
const variantDef = { | ||
name: 'TEST-IOS', | ||
type: 'ios', | ||
certificate: 'test/resources/mockcert.p12', | ||
passphrase: 'PASSWORD', | ||
production: false, | ||
} as IOSVariantDefinition; | ||
|
||
const argv = { | ||
url: 'http://localhost:9999', | ||
appId: app.pushApplicationID, | ||
output: 'json', | ||
...variantDef, | ||
}; | ||
|
||
const variantID = IDGenerator.peek(); | ||
|
||
// @ts-ignore | ||
await handler(argv); | ||
expect(ConsoleMock.log).toHaveBeenCalledTimes(1); | ||
expect(JSON.parse(ConsoleMock.log.mock.calls[0][0])).toEqual([ | ||
app.variants?.find(v => v.variantID === variantID), | ||
]); | ||
}); | ||
}); |
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,59 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-ignore */ | ||
import {ConsoleMock} from '../../../mocks'; | ||
import { | ||
createApplication, | ||
getAllApplications, | ||
initMockEngine, | ||
} from '../../../mocks/UPSMock'; | ||
import {IDGenerator} from '../../../mocks/DataStore'; | ||
import {IOSTokenVariantDefinition} from '@aerogear/unifiedpush-admin-client'; | ||
import {handler} from '../../../../src/cmds/variants-cmds/create-cmds/iosToken'; | ||
|
||
beforeEach(() => { | ||
// Clear all instances and calls to constructor and all methods: | ||
initMockEngine(); | ||
createApplications(10); | ||
ConsoleMock.init(); | ||
ConsoleMock.mockClear(); | ||
}); | ||
|
||
afterEach(() => { | ||
ConsoleMock.uninstall(); | ||
}); | ||
|
||
const createApplications = (howmany: number) => { | ||
for (let i = 0; i < howmany; i++) { | ||
createApplication(`TEST APP-${i}`); | ||
} | ||
}; | ||
|
||
describe('variants create', () => { | ||
it('Should create an ios-token variants', async () => { | ||
const app = getAllApplications()[3]; | ||
const variantDef = { | ||
name: 'TEST-IOS', | ||
type: 'ios_token', | ||
production: false, | ||
teamId: 'team', | ||
keyId: 'test-key', | ||
bundleId: 'bundle-id', | ||
privateKey: 'test/resources/mock-pkey.pem', | ||
} as IOSTokenVariantDefinition; | ||
|
||
const argv = { | ||
url: 'http://localhost:9999', | ||
appId: app.pushApplicationID, | ||
output: 'json', | ||
...variantDef, | ||
}; | ||
|
||
const variantID = IDGenerator.peek(); | ||
// @ts-ignore | ||
await handler(argv); | ||
|
||
const newVariant = app.variants?.find(v => v.variantID === variantID)!; | ||
expect(ConsoleMock.log).toHaveBeenCalledTimes(1); | ||
expect(JSON.parse(ConsoleMock.log.mock.calls[0][0])).toEqual([newVariant]); | ||
expect(newVariant.type).toEqual('ios_token'); | ||
}); | ||
}); |
57 changes: 57 additions & 0 deletions
57
test/cmds/variants-cmds/create-cmds/webPushVariant.test.ts
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 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-ignore */ | ||
import {ConsoleMock} from '../../../mocks'; | ||
import { | ||
createApplication, | ||
getAllApplications, | ||
initMockEngine, | ||
} from '../../../mocks/UPSMock'; | ||
import {IDGenerator} from '../../../mocks/DataStore'; | ||
import {WebPushVariantDefinition} from '@aerogear/unifiedpush-admin-client'; | ||
import {handler} from '../../../../src/cmds/variants-cmds/create-cmds/webpushVariant'; | ||
|
||
beforeEach(() => { | ||
// Clear all instances and calls to constructor and all methods: | ||
initMockEngine(); | ||
createApplications(10); | ||
ConsoleMock.init(); | ||
ConsoleMock.mockClear(); | ||
}); | ||
|
||
afterEach(() => { | ||
ConsoleMock.uninstall(); | ||
}); | ||
|
||
const createApplications = (howmany: number) => { | ||
for (let i = 0; i < howmany; i++) { | ||
createApplication(`TEST APP-${i}`); | ||
} | ||
}; | ||
|
||
describe('webpush variants create', () => { | ||
it('Should create an web_push variants', async () => { | ||
const app = getAllApplications()[3]; | ||
const variantDef = { | ||
name: 'TEST-WEBPUSH', | ||
type: 'web_push', | ||
publicKey: 'public key', | ||
privateKey: 'private key', | ||
alias: 'mailto:test@aerogear.com', | ||
} as WebPushVariantDefinition; | ||
|
||
const argv = { | ||
url: 'http://localhost:9999', | ||
appId: app.pushApplicationID, | ||
output: 'json', | ||
...variantDef, | ||
}; | ||
|
||
const variantID = IDGenerator.peek(); | ||
// @ts-ignore | ||
await handler(argv); | ||
|
||
const newVariant = app.variants?.find(v => v.variantID === variantID)!; | ||
expect(ConsoleMock.log).toHaveBeenCalledTimes(1); | ||
expect(JSON.parse(ConsoleMock.log.mock.calls[0][0])).toEqual([newVariant]); | ||
expect(newVariant.type).toEqual('web_push'); | ||
}); | ||
}); |
Oops, something went wrong.