Files
privacy.sexy/tests/unit/application/Environment/BrowserOs/BrowserOsDetector.spec.ts
undergroundwires 60c80611ea add module alias '@tests/'
Alias would remove unnecessary repetitions and less relative paths make changes easier when moving around files. This commit cleans also up some relative paths ('../../../') by using the alias and orders imports. It updates both path alias in tsconfig and module alias in Vue CLI's bundler (vuejs/vue-cli#2398).
2021-04-15 18:34:40 +02:00

31 lines
1.1 KiB
TypeScript

import 'mocha';
import { expect } from 'chai';
import { OperatingSystem } from '@/domain/OperatingSystem';
import { BrowserOsDetector } from '@/application/Environment/BrowserOs/BrowserOsDetector';
import { BrowserOsTestCases } from './BrowserOsTestCases';
describe('BrowserOsDetector', () => {
it('returns undefined when user agent is undefined', () => {
// arrange
const expected = undefined;
const sut = new BrowserOsDetector();
// act
const actual = sut.detect(undefined);
// assert
expect(actual).to.equal(expected);
});
it('detects as expected', () => {
for (const testCase of BrowserOsTestCases) {
// arrange
const sut = new BrowserOsDetector();
// act
const actual = sut.detect(testCase.userAgent);
// assert
expect(actual).to.equal(testCase.expectedOs,
`Expected: "${OperatingSystem[testCase.expectedOs]}"\n` +
`Actual: "${OperatingSystem[actual]}"\n` +
`UserAgent: "${testCase.userAgent}"`);
}
});
});