describe('InfoHelper', () => { describe('#getName', () => { it('returns the app name', () => { expect(InfoHelper.getName()).toBeTruthy() }) }) describe('#getVersion', () => { it('return the app version', () => { expect(InfoHelper.getVersion()).toMatch(/\d\.\d\.\d/) }) }) })
it('Test 035 : should fetch shared resources if platform parameter is not specified', function () { expect(cfg.getStaticResources(null, 'icon').length).toBe(2); expect(cfg.getStaticResources(null, 'icon').every(hasPlatformPropertyUndefined)).toBeTruthy(); });
describe('file resources', function () { const hasSrcPropertyDefined = function (e) { return !!e.src; }; const hasTargetPropertyDefined = function (e) { return !!e.target; }; const hasArchPropertyDefined = function (e) { return !!e.arch; }; it('should fetch platform-specific resources', function () { expect(cfg.getFileResources('android').length).toBe(2); }); it('should parse resources\' attributes', function () { expect(cfg.getFileResources('android').every(hasSrcPropertyDefined)).toBeTruthy(); expect(cfg.getFileResources('android').every(hasTargetPropertyDefined)).toBeTruthy(); expect(cfg.getFileResources('windows').every(hasArchPropertyDefined)).toBeTruthy(); }); it('should find resources at the top level', function () { expect(cfg.getFileResources('android', true).length).toBe(3); }); });
describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], }).compileComponents(); })); it('should create the app', async(() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); })); it(`should have as title 'client'`, async(() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app.title).toEqual('client'); })); it('should render title in a h1 tag', async(() => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain('Welcome to client!'); })); });
it('Test 037 : should parse resources\' attributes', function () { expect(cfg.getStaticResources(null, 'icon').every(hasSrcPropertyDefined)).toBeTruthy(); expect(cfg.getStaticResources('windows', 'icon').filter(hasPlatformPropertyDefined).every(hasTargetPropertyDefined)).toBeTruthy(); expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy(); expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy(); });
describe('wasModifiedSince', function () { describe('checks a date and a modification string', function () { it('returns an error if modification string is not a serialized date', function () { let d = new Date(); expect(function () { sut.wasModifiedSince(d, 'Not a Date'); }).toThrow(); }); it('returns true if date is older than modification string', function () { let date = new Date('2017-12-21T12:32:12'); let modifiedDate = '2016-12-21T12:32:12'; expect(sut.wasModifiedSince(date, modifiedDate)).toBeTruthy(); }); it('returns true if modification date is not defined', function () { let date = new Date('2017-12-21T12:32:12'); expect(sut.wasModifiedSince(date, undefined)).toBeTruthy(); }); it('returns false if date is newer than modification string', function () { let date = new Date('2016-12-21T12:32:12'); let modifiedDate = '2017-12-21T12:32:12'; expect(sut.wasModifiedSince(date, modifiedDate)).not.toBeTruthy(); }); }); });
}, (error, response, body) => { expect(error).toBe(null); expect(body).toBeTruthy(); expect(body.id).toBeTruthy(); expect(body.location).toBe(this.requestBody.location); expect(body.temperature.celsius).toBe(this.requestBody.temperature.celsius); }, (error, response, body) => { expect(error).toBe(null); expect(body).toBeTruthy(); expect(body.id).toBe(this.id); expect(body.location).toBe(this.requestBody.location);
}); expect(value).toBeTruthy(); expect(value).toBeConverted(this.expected); }); }); expect(value).toBeTruthy(); expect(value).toBeConverted(this.expected); });
it('rejects in case a url is not provided', function () { helper().catch(function (err) { expect(err instanceof TypeError).toBeTruthy(); }); }); it('rejects in case method is overridden', function () { helper('https://npmjs.org', { method: 'PUT' }).catch(function (err) { expect(err instanceof Error).toBeTruthy(); }); }); }; result = helper('https://npmjs.org', {}, FakeImplementation); expect(FakeImplementation.prototype.isPrototypeOf(result)).toBeTruthy(); }); });
it('Test 036 : should fetch platform-specific resources along with shared if platform parameter is specified', function () { expect(cfg.getStaticResources('android', 'icon').length).toBe(5); expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyDefined)).toBeTruthy(); expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).length).toBe(3); expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyUndefined)).toBeTruthy(); });