let service: SettingsService;
let httpTesting: HttpTestingController;
+ const exampleUrl = 'api/settings/something';
+ const exampleValue = 'http://localhost:3000';
+
configureTestBed(
{
providers: [SettingsService],
});
describe('isSettingConfigured', () => {
- const exampleUrl = 'api/settings/something';
- const exampleValue = 'http://localhost:3000';
let increment: number;
const testConfig = (url, value) => {
- service.ifSettingConfigured(url, (setValue) => {
- expect(setValue).toBe(value);
- increment++;
- });
+ service.ifSettingConfigured(
+ url,
+ (setValue) => {
+ expect(setValue).toBe(value);
+ increment++;
+ },
+ () => {
+ increment--;
+ }
+ );
};
const expectSettingsApiCall = (url: string, value: object, isSet: string) => {
expect(req.request.method).toBe('GET');
req.flush(value);
tick();
- expect(increment).toBe(isSet !== '' ? 1 : 0);
+ expect(increment).toBe(isSet !== '' ? 1 : -1);
expect(service['settings'][url]).toBe(isSet);
};
expect(increment).toBe(2);
}));
});
+
+ it('should disable a set setting', () => {
+ service['settings'] = { [exampleUrl]: exampleValue };
+ service.disableSetting(exampleUrl);
+ expect(service['settings']).toEqual({ [exampleUrl]: '' });
+ });
});