Skip to content

Commit

Permalink
Attempt to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownskl committed Sep 25, 2024
1 parent 101ead3 commit f485808
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"xcloudapi": "yarn workspace @greenlight/xcloudapi",
"webapi": "yarn workspace @greenlight/webapi",
"platform": "yarn workspace @greenlight/platform",
"test": "yarn logger test && yarn authentication test && yarn storeapi test && yarn xcloudapi test"
"test": "yarn authentication test && yarn logger test && yarn storeapi test && yarn xcloudapi test && yarn webapi test && yarn platform test"
},
"workspaces": [
"app",
Expand Down
4 changes: 2 additions & 2 deletions packages/authentication/src/authstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default class AuthStore extends TokenStore {
}

const getAppBasePath = () => {
let ElectronAppName = '@greenlight/app2 (development)'
let ElectronAppName = '@greenlight/app3 (development)'
if(process.env.NODE_ENV === 'production')
ElectronAppName = '@greenlight/app'
ElectronAppName = '@greenlight/app3'

if(app !== undefined && app.getPath !== undefined)
return app.getPath('userData')
Expand Down
15 changes: 15 additions & 0 deletions packages/platform/src/controllers/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import GreenlightPlatform from '..'

export default class App {

private _platform:GreenlightPlatform

constructor(platform:GreenlightPlatform){
this._platform = platform
}

ping() {
return 'pong'
}

}
4 changes: 3 additions & 1 deletion packages/platform/src/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Authentication from './authentication'
import Gamepass from './gamepass'
import App from './app'

export default {
Authentication: Authentication,
Gamepass: Gamepass
Gamepass: Gamepass,
App: App,
}
8 changes: 4 additions & 4 deletions packages/platform/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import Logger from '@greenlight/logger'

import PlatformWorker, { WorkerMessage, WorkerMessageResponse } from './worker'

import Authentication from './controllers/authentication'
import Gamepass from './controllers/gamepass'
import Controllers from './controllers'

export default class GreenlightPlatform {

Expand All @@ -14,8 +13,9 @@ export default class GreenlightPlatform {
private _platformWorker?:PlatformWorker

public api = {
Authentication: new Authentication(this),
Gamepass: new Gamepass(this),
App: new Controllers.App(this),
Authentication: new Controllers.Authentication(this),
Gamepass: new Controllers.Gamepass(this),
}

constructor() {
Expand Down
31 changes: 28 additions & 3 deletions packages/platform/tests/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
import GreenlightPlatform from '../src/index'
import GreenlightPlatform from '../dist/index'
import { expect } from 'chai'

describe('GreenlightPlatform', () => {

describe('new instance', () => {
it('should create an instance of GreenlightPlatform', function(){
const auth = new GreenlightPlatform()
expect(auth).to.be.an.instanceOf(GreenlightPlatform)
const platform = new GreenlightPlatform()
expect(platform).to.be.an.instanceOf(GreenlightPlatform)
})
})

describe('load worker', () => {
it('should be able to load', async function(){
const platform = new GreenlightPlatform()
expect(platform).to.be.an.instanceOf(GreenlightPlatform)

const workerState = await platform.loadWorker()
expect(workerState).to.be.oneOf([true, false])

await platform.close()
})

it('should be able to retrieve data', async function(){
const platform = new GreenlightPlatform()
expect(platform).to.be.an.instanceOf(GreenlightPlatform)

const workerState = await platform.loadWorker()
expect(workerState).to.be.oneOf([true, false])

const pingReply = await platform.api.App.ping()
expect(pingReply).to.equal('pong')

await platform.close()
})
})
})
1 change: 0 additions & 1 deletion packages/storeapi/tests/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import StoreApi from '../src/index'
import { Xal } from 'xal-node'

import { expect } from 'chai'

Expand Down
7 changes: 5 additions & 2 deletions packages/webapi/tests/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ describe('WebApi', () => {
describe('new instance', () => {
it('should create an instance of WebApi', function(){
const auth = new WebApi({
host: 'dummy',
token: 'dummytoken'
uhs: 'dummy',
token: {
Token: 'dummytoken',
NotAfter: '0'
}
})
expect(auth).to.be.an.instanceOf(WebApi)
})
Expand Down

0 comments on commit f485808

Please sign in to comment.