unity-builder/src/model/unity-versioning.test.ts
Webber Takken 4fde4e47b6
Refactor action to typescript (#226)
* Refactor to typescript (config part)

* Refactor to typescript (convert extensions, minor fixes)

* Refactor to typescript (move from `action` to `dist`)

* Re-enable integrity-check for dist index.js

* Fix all tests and lints

* fix parsing major versions

* Test patch level to be digits only

* debug

* debug

* uncache

* manual compile

* debug

* debug

* Debug

* Build lib - doh

* remove diff check

* Make kubernetes workflow manual

* Properly generate 3 digit for simple major tags

* Remove ts-ignore

* re-enable cache
2021-03-14 00:44:01 +01:00

36 lines
1.1 KiB
TypeScript

import UnityVersioning from './unity-versioning';
describe('Unity Versioning', () => {
describe('parse', () => {
it('throws for empty string', () => {
expect(() => UnityVersioning.parse('')).toThrow(Error);
});
it('parses from ProjectVersion.txt', () => {
const projectVersionContents = `m_EditorVersion: 2019.2.11f1
m_EditorVersionWithRevision: 2019.2.11f1 (5f859a4cfee5)`;
expect(UnityVersioning.parse(projectVersionContents)).toBe('2019.2.11f1');
});
});
describe('read', () => {
it('does not throw', () => {
expect(() => UnityVersioning.read('')).not.toThrow();
});
it('reads from test-project', () => {
expect(UnityVersioning.read('./test-project')).toBe('2019.2.11f1');
});
});
describe('determineUnityVersion', () => {
it('defaults to parsed version', () => {
expect(UnityVersioning.determineUnityVersion('./test-project', 'auto')).toBe('2019.2.11f1');
});
it('use specified unityVersion', () => {
expect(UnityVersioning.determineUnityVersion('./test-project', '1.2.3')).toBe('1.2.3');
});
});
});