Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(authorizenet): add credit card factory #2843

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libs/authorizenet/testing/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "../../../node_modules/ng-packagr/ng-entrypoint.schema.json",
"lib": {
"entryFile": "src/index.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { TestBed } from '@angular/core/testing';

import { DaffAuthorizeNetCreditCard } from '@daffodil/authorizenet';

import { DaffAuthorizeNetCreditCardFactory } from './credit-card.factory';

describe('@daffodil/payment/testing | DaffAuthorizeNetCreditCardFactory', () => {
let paymentResponseFactory: DaffAuthorizeNetCreditCardFactory;
griest024 marked this conversation as resolved.
Show resolved Hide resolved

beforeEach(() => {
TestBed.configureTestingModule({
providers: [DaffAuthorizeNetCreditCardFactory],
});

paymentResponseFactory = TestBed.inject(DaffAuthorizeNetCreditCardFactory);
});

it('should be created', () => {
expect(paymentResponseFactory).toBeTruthy();
});

describe('create', () => {
let result: DaffAuthorizeNetCreditCard;

beforeEach(() => {
result = paymentResponseFactory.create();
});

it('should return', () => {
expect(result).toBeDefined();
});

it('should define all the required fields', () => {
expect(result.cardnumber).toBeDefined();
expect(result.month).toBeDefined();
expect(result.year).toBeDefined();
expect(result.securitycode).toBeDefined();
});
});
});
27 changes: 27 additions & 0 deletions libs/authorizenet/testing/src/factories/credit-card.factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';
import { faker } from '@faker-js/faker/locale/en_US';

import { DaffAuthorizeNetCreditCard } from '@daffodil/authorizenet';
import { DaffModelFactory } from '@daffodil/core/testing';

/**
* Mock class for {@link DaffAuthorizeNetCreditCard}.
*/
export class MockDaffAuthorizeNetCreditCard implements DaffAuthorizeNetCreditCard {
cardnumber = faker.finance.creditCardNumber();
month = faker.date.month();
year = faker.date.future().getFullYear().toString();
securitycode = faker.finance.creditCardCVV();
};

/**
* Model factory for {@link DaffAuthorizeNetCreditCard}.
*/
@Injectable({
providedIn: 'root',
})
export class DaffAuthorizeNetCreditCardFactory extends DaffModelFactory<DaffAuthorizeNetCreditCard, typeof MockDaffAuthorizeNetCreditCard>{
constructor() {
super(MockDaffAuthorizeNetCreditCard);
}
}
1 change: 1 addition & 0 deletions libs/authorizenet/testing/src/factories/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './credit-card.factory';
1 change: 1 addition & 0 deletions libs/authorizenet/testing/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './public_api';
1 change: 1 addition & 0 deletions libs/authorizenet/testing/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './factories/public_api';
3 changes: 3 additions & 0 deletions libs/authorizenet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"@daffodil/authorizenet": [
"libs/authorizenet/src"
],
"@daffodil/authorizenet/testing": [
"libs/authorizenet/testing/src"
],
"@daffodil/authorizenet/state": [
"libs/authorizenet/state/src"
],
Expand Down
Loading