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' , ( ) => { const expected = undefined ; const sut = new BrowserOsDetector ( ) ; const actual = sut . detect ( undefined ) ; expect ( actual ) . to . equal ( expected ) ; } ) ; it ( 'detects as expected' , ( ) => { BrowserOsTestCases . forEach ( ( testCase ) => { const sut = new BrowserOsDetector ( ) ; const actual = sut . detect ( testCase . userAgent ) ; expect ( actual ) . to . equal ( testCase . expectedOs , printMessage ( ) ) ; function printMessage ( ) { return `Expected: "${ OperatingSystem [ testCase . expectedOs ] }"\n` + `Actual: "${ OperatingSystem [ actual ] }"\n` + `UserAgent: "${ testCase . userAgent }"` ; } } ) ; } ) ; } ) ;