Skip to content

Commit

Permalink
chore(parameters): fix code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamorosi committed Oct 20, 2023
1 parent 8026e19 commit 2f23aee
Showing 1 changed file with 34 additions and 52 deletions.
86 changes: 34 additions & 52 deletions packages/parameters/tests/unit/BaseProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,46 @@ jest.mock('@aws-lambda-powertools/commons', () => ({
addUserAgentMiddleware: jest.fn(),
}));

describe('Class: BaseProvider', () => {
afterEach(() => {
jest.clearAllMocks();
});

class TestProvider extends BaseProvider {
public constructor() {
super({
proto: class {
#name = 'TestProvider';

public hello(): string {
return this.#name;
}
},
});
}
class TestProvider extends BaseProvider {
public constructor() {
super({
proto: class {
#name = 'TestProvider';

public hello(): string {
return this.#name;
}
},
});
}

public _add(key: string, value: ExpirableValue): void {
this.store.set(key, value);
}
public _add(key: string, value: ExpirableValue): void {
this.store.set(key, value);
}

public _get(_name: string): Promise<string> {
throw Error('Not implemented.');
}
public _get(_name: string): Promise<string> {
throw Error('Not implemented.');
}

public _getKeyTest(key: string): ExpirableValue | undefined {
return this.store.get(key);
}
public _getKeyTest(key: string): ExpirableValue | undefined {
return this.store.get(key);
}

public _getMultiple(
_path: string
): Promise<Record<string, string | undefined>> {
throw Error('Not implemented.');
}
public _getMultiple(
_path: string
): Promise<Record<string, string | undefined>> {
throw Error('Not implemented.');
}

public _getStoreSize(): number {
return this.store.size;
}
public _getStoreSize(): number {
return this.store.size;
}
}

describe('Class: BaseProvider', () => {
afterEach(() => {
jest.clearAllMocks();
});

describe('Method: addToCache', () => {
test('when called with a value and maxAge equal to 0, it skips the cache entirely', () => {
Expand Down Expand Up @@ -597,24 +597,6 @@ describe('Class: BaseProvider', () => {
});

describe('Function: clearCaches', () => {
class TestProvider extends BaseProvider {
public constructor() {
super({
proto: class {},
});
}

public _get(_name: string): Promise<string> {
throw Error('Not implemented.');
}

public _getMultiple(
_path: string
): Promise<Record<string, string | undefined>> {
throw Error('Not implemented.');
}
}

test('when called, it clears all the caches', () => {
// Prepare
const provider1 = new TestProvider();
Expand Down

0 comments on commit 2f23aee

Please sign in to comment.