-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for version info gathering
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
packages/web-runtime/tests/unit/container/versions.spec.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,52 @@ | ||
import { getBackendVersion, getWebVersion } from '../../../src/container/versions' | ||
import Vuex, { Store } from 'vuex' | ||
import Vue from 'vue' | ||
|
||
Vue.use(Vuex) | ||
|
||
describe('collect version information', () => { | ||
describe('web version', () => { | ||
beforeEach(() => { | ||
process.env.PACKAGE_VERSION = '4.7.0' | ||
}) | ||
it('provides the web version with a static string without exceptions', () => { | ||
expect(getWebVersion()).toBe('ownCloud Web UI 4.7.0') | ||
}) | ||
}) | ||
describe('backend version', () => { | ||
it('returns undefined when the backend version object is not available', () => { | ||
const store = versionStore(undefined) | ||
expect(getBackendVersion({ store })).toBeUndefined() | ||
}) | ||
it('returns undefined when the backend version object has no "string" field', () => { | ||
const store = versionStore({ | ||
product: 'ownCloud', | ||
string: undefined | ||
}) | ||
expect(getBackendVersion({ store })).toBeUndefined() | ||
}) | ||
it('falls back to "ownCloud" as a product when none is defined', () => { | ||
const store = versionStore({ | ||
string: '10.8.0', | ||
edition: 'Community' | ||
}) | ||
expect(getBackendVersion({ store })).toBe('ownCloud 10.8.0 Community') | ||
}) | ||
it('provides the backend version as concatenation of product, version and edition', () => { | ||
const store = versionStore({ | ||
product: 'oCIS', | ||
string: '1.16.0', | ||
edition: 'Reva' | ||
}) | ||
expect(getBackendVersion({ store })).toBe('oCIS 1.16.0 Reva') | ||
}) | ||
}) | ||
}) | ||
|
||
const versionStore = (version: any): Store<any> => { | ||
return new Vuex.Store({ | ||
getters: { | ||
user: jest.fn(() => ({ version })) | ||
} | ||
}) | ||
} |