-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Set up worker architecture based on Nest microservices
Relates to #115
- Loading branch information
1 parent
973acad
commit 508bafd
Showing
26 changed files
with
704 additions
and
662 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { CurrencyCode, LanguageCode } from '@vendure/common/lib/generated-types'; | ||
|
||
import { Channel } from '../../entity/channel/channel.entity'; | ||
import { Order } from '../../entity/order/order.entity'; | ||
import { AuthenticatedSession } from '../../entity/session/authenticated-session.entity'; | ||
import { Session } from '../../entity/session/session.entity'; | ||
import { User } from '../../entity/user/user.entity'; | ||
import { Zone } from '../../entity/zone/zone.entity'; | ||
|
||
import { RequestContext } from './request-context'; | ||
|
||
describe('RequestContext', () => { | ||
|
||
describe('fromObject()', () => { | ||
|
||
let original: RequestContext; | ||
let ctxObject: object; | ||
let session: Session; | ||
let user: User; | ||
let channel: Channel; | ||
let activeOrder: Order; | ||
let zone: Zone; | ||
|
||
beforeAll(() => { | ||
activeOrder = new Order({ | ||
id: '55555', | ||
active: true, | ||
code: 'ADAWDJAWD', | ||
}); | ||
user = new User({ | ||
id: '8833774', | ||
verified: true, | ||
}); | ||
session = new AuthenticatedSession({ | ||
id: '1234', | ||
token: '2d37187e9e8fc47807fe4f58ca', | ||
activeOrder, | ||
user, | ||
}); | ||
zone = new Zone({ | ||
id: '62626', | ||
name: 'Europe', | ||
}); | ||
channel = new Channel({ | ||
token: 'oiajwodij09au3r', | ||
id: '995859', | ||
code: '__default_channel__', | ||
currencyCode: CurrencyCode.EUR, | ||
pricesIncludeTax: true, | ||
defaultLanguageCode: LanguageCode.en, | ||
defaultShippingZone: zone, | ||
defaultTaxZone: zone, | ||
}); | ||
original = new RequestContext({ | ||
apiType: 'admin', | ||
languageCode: LanguageCode.en, | ||
channel, | ||
session, | ||
isAuthorized: true, | ||
authorizedAsOwnerOnly: false, | ||
}); | ||
|
||
ctxObject = JSON.parse(JSON.stringify(original)); | ||
}); | ||
|
||
it('apiType', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.apiType).toBe(original.apiType); | ||
}); | ||
|
||
it('channelId', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.channelId).toBe(original.channelId); | ||
}); | ||
|
||
it('languageCode', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.languageCode).toBe(original.languageCode); | ||
}); | ||
|
||
it('activeUserId', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.activeUserId).toBe(original.activeUserId); | ||
}); | ||
|
||
it('isAuthorized', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.isAuthorized).toBe(original.isAuthorized); | ||
}); | ||
|
||
it('authorizedAsOwnerOnly', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.authorizedAsOwnerOnly).toBe(original.authorizedAsOwnerOnly); | ||
}); | ||
|
||
it('channel', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.channel).toEqual(original.channel); | ||
}); | ||
|
||
it('session', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.session).toEqual(original.session); | ||
}); | ||
|
||
it('activeUser', () => { | ||
const result = RequestContext.fromObject(ctxObject); | ||
expect(result.activeUser).toEqual(original.activeUser); | ||
}); | ||
|
||
}); | ||
|
||
}); |
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
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
Oops, something went wrong.