import {NativeLibraryWrapperService} from '../native-library-wrapper.service'; import {QuotedPrintableDecoder} from './quoted-printable-decoder'; import createSpyObj = jasmine.createSpyObj; import Spy = jasmine.Spy; describe('QuotedPrintableDecoder', () => { let sut: QuotedPrintableDecoder; let nativeWrapperSpy: Partial; let decodeSpy: Spy; beforeEach(() => { nativeWrapperSpy = {quotedPrintable: createSpyObj(['decode'])}; decodeSpy = nativeWrapperSpy.quotedPrintable.decode as Spy; sut = new QuotedPrintableDecoder((nativeWrapperSpy as NativeLibraryWrapperService)); }); it('should create an instance', () => { expect(sut).toBeTruthy(); }); it('should have a display name', () => { expect(sut.getDisplayname()).toBeTruthy(); }); it('should have the id "decodequotedprintable"', () => { expect(sut.getId()).toEqual('decodequotedprintable'); }); it('should call through to the native quoted printable decoder', () => { const testInput = 'My input'; const expectedOutput = 'It worked'; decodeSpy.and.returnValue(expectedOutput); const result: string = sut.convert(testInput); expect(result).toEqual(expectedOutput); expect(decodeSpy).toHaveBeenCalledWith(testInput); }); });