From: Bill Erickson Date: Thu, 17 May 2018 18:01:59 +0000 (-0400) Subject: LP#1775466 Unit tests setup / ported EgEventService test X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6d3d1f8ed97baa78522b4ecc3eed559d717b52e8;p=working%2FEvergreen.git LP#1775466 Unit tests setup / ported EgEventService test Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/karma.conf.js b/Open-ILS/src/eg2/karma.conf.js index 84af9d19ad..bed8c6fbf0 100644 --- a/Open-ILS/src/eg2/karma.conf.js +++ b/Open-ILS/src/eg2/karma.conf.js @@ -8,6 +8,7 @@ module.exports = function (config) { plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), + require('karma-phantomjs-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), require('@angular-devkit/build-angular/plugins/karma') @@ -27,7 +28,7 @@ module.exports = function (config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['Chrome'], - singleRun: false + browsers: ['PhantomJS'], + singleRun: true }); }; diff --git a/Open-ILS/src/eg2/package.json b/Open-ILS/src/eg2/package.json index 2816c9ac15..0955f5c570 100644 --- a/Open-ILS/src/eg2/package.json +++ b/Open-ILS/src/eg2/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "@angular-devkit/build-angular": "~0.6.1", - "@angular/cli": "6.0.1", + "@angular/cli": "^6.0.1", "@angular/compiler-cli": "6.0.1", "@angular/language-service": "6.0.1", "@types/jasmine": "~2.5.53", @@ -45,6 +45,7 @@ "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", + "karma-phantomjs-launcher": "^1.0.4", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", diff --git a/Open-ILS/src/eg2/src/app/core/event.spec.ts b/Open-ILS/src/eg2/src/app/core/event.spec.ts new file mode 100644 index 0000000000..a14f89bd4f --- /dev/null +++ b/Open-ILS/src/eg2/src/app/core/event.spec.ts @@ -0,0 +1,45 @@ +import {EgEventService} from './event.service'; + +describe('EgEventService', function(){ + let service: EgEventService; + beforeEach(() => {service = new EgEventService();}); + + let evt = { + ilsevent: "12345", + pid: "12345", + desc: "Test Event Description", + payload: {test : 'xyz'}, + textcode: "TEST_EVENT", + servertime: "Wed Nov 6 16:05:50 2013" + }; + + it('should parse an event object', () => { + expect(service.parse(evt)).not.toBe(null); + }); + + it('should not parse a non-event', () => { + expect(service.parse({})).toBe(null); + }); + + it('should not parse a non-event', () => { + expect(service.parse({abc : '123'})).toBe(null); + }); + + it('should not parse a non-event', () => { + expect(service.parse([])).toBe(null); + }); + + it('should not parse a non-event', () => { + expect(service.parse('STRING')).toBe(null); + }); + + it('should not parse a non-event', () => { + expect(service.parse(true)).toBe(null); + }); + + it('should stringify an event', () => { + expect(service.parse(evt).toString()).toBe( + 'Event: 12345:TEST_EVENT -> Test Event Description') + }); + +}); diff --git a/Open-ILS/src/eg2/src/polyfills.ts b/Open-ILS/src/eg2/src/polyfills.ts index 20d40751a6..e073082c1c 100644 --- a/Open-ILS/src/eg2/src/polyfills.ts +++ b/Open-ILS/src/eg2/src/polyfills.ts @@ -34,6 +34,10 @@ // import 'core-js/es6/weak-map'; // import 'core-js/es6/set'; +// PhantomJS needs these +import 'core-js/es6/array'; +import 'core-js/es6/string'; + /** IE10 and IE11 requires the following for NgClass support on SVG elements */ // import 'classlist.js'; // Run `npm install --save classlist.js`.