Skip to content

Commit

Permalink
fix: mock context
Browse files Browse the repository at this point in the history
  • Loading branch information
acnormun committed Dec 5, 2024
1 parent 19efb40 commit ad46882
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 43 deletions.
60 changes: 17 additions & 43 deletions src/components/flow/actions/openticket/OpenTicket.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const mockContext = {
},
};

const ConfigContext = React.createContext(mockContext);

describe('OpenTicketComp', () => {
it('should render subject if provided', () => {
const props = {
Expand All @@ -20,14 +18,10 @@ describe('OpenTicketComp', () => {
result_name: 'Result Name',
type: Types.open_ticket,
uuid: '5678',
context: mockContext,
};

render(
<ConfigContext.Provider value={mockContext}>
<OpenTicketComp {...props} />
</ConfigContext.Provider>,
);

render(<OpenTicketComp {...props} />);
expect(screen.getByText('Test Subject')).toBeInTheDocument();
});

Expand All @@ -39,60 +33,40 @@ describe('OpenTicketComp', () => {
result_name: 'Result Name',
type: Types.open_ticket,
uuid: '5678',
context: mockContext,
};

render(
<ConfigContext.Provider value={mockContext}>
<OpenTicketComp {...props} />
</ConfigContext.Provider>,
);
render(<OpenTicketComp {...props} context={mockContext} />);

expect(screen.getByText('Test Topic')).toBeInTheDocument();
});

it('should display ticketer name if brand is not present in ticketer name', () => {
const props = {
context: {
config: {
brand: 'MyBrand',
},
},
ticketer: { name: 'Another Brand Support', uuid: '1234' },
body: 'This is the body',
result_name: 'Result Name',
type: Types.open_ticket,
uuid: '5678',
context: mockContext,
};

render(
<ConfigContext.Provider value={mockContext}>
<OpenTicketComp {...props} />
</ConfigContext.Provider>,
);
render(<OpenTicketComp {...props} />);

expect(screen.getByText(/Another Brand Support/)).toBeInTheDocument();
});

// it('should not display ticketer name if brand is in ticketer name', () => {
// const props = {
// context: {
// config: {
// brand: 'MyBrand',
// },
// },
// ticketer: { name: 'MyBrand Support', uuid: '1234' },
// body: 'This is the body',
// result_name: 'Result Name',
// type: Types.open_ticket,
// uuid: '5678',
// };
it('should not display ticketer name if brand is in ticketer name', () => {
const props = {
ticketer: { name: 'MyBrand Support', uuid: '1234' },
body: 'This is the body',
result_name: 'Result Name',
type: Types.open_ticket,
uuid: '5678',
};

// render(
// <ConfigContext.Provider value={mockContext}>
// <OpenTicketComp {...props} />
// </ConfigContext.Provider>,
// );
render(<OpenTicketComp {...props} context={mockContext} />);

// expect(screen.queryByText(/Using/)).not.toBeInTheDocument();
// });
expect(screen.queryByText(/Using/)).not.toBeInTheDocument();

Check failure on line 70 in src/components/flow/actions/openticket/OpenTicket.test.tsx

View workflow job for this annotation

GitHub Actions / Coverage

components/flow/actions/openticket/OpenTicket.test.tsx > OpenTicketComp > should not display ticketer name if brand is in ticketer name

Error: expect(element).not.toBeInTheDocument() expected document not to contain element, found <div style="font-size: 80%;" > Using aaaa {} <span style="font-weight: 400;" > MyBrand Support </span> </div> instead ❯ components/flow/actions/openticket/OpenTicket.test.tsx:70:45

Check failure on line 70 in src/components/flow/actions/openticket/OpenTicket.test.tsx

View workflow job for this annotation

GitHub Actions / Tests (18.x)

components/flow/actions/openticket/OpenTicket.test.tsx > OpenTicketComp > should not display ticketer name if brand is in ticketer name

Error: expect(element).not.toBeInTheDocument() expected document not to contain element, found <div style="font-size: 80%;" > Using aaaa {} <span style="font-weight: 400;" > MyBrand Support </span> </div> instead ❯ components/flow/actions/openticket/OpenTicket.test.tsx:70:45
});
});
1 change: 1 addition & 0 deletions src/flowTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ export interface OpenTicket extends Action {
body: string;
result_name: string;
assignee?: User;
context?: any;
}

export interface StartFlow extends Action {
Expand Down

0 comments on commit ad46882

Please sign in to comment.