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

testing #17

Open
two-ticks opened this issue Jul 4, 2021 · 3 comments
Open

testing #17

two-ticks opened this issue Jul 4, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@two-ticks
Copy link
Owner

two-ticks commented Jul 4, 2021

I want to test whether add method is called or not. I have tried these ways but all are giving the same error.

it('add should be called', () => {
  const tex = createTeX('2^2');
  const spy = jest.spyOn(tex, 'add');
  tex.add();
  expect(spy).toHaveBeenCalled();
  //expect(tex.position()).toEqual([10, 20]);
});
it('add should be called', () => {
  const tex = createTeX('2^2');
  const element = createDiv();
  global.createDiv = function(html){return element}
  const spy = jest.spyOn(tex, 'add');
  tex.add();
  expect(spy).toHaveBeenCalled();
  //expect(tex.position()).toEqual([10, 20]);
});

image

other working tests in commit : 0ed4891

@two-ticks two-ticks added the bug Something isn't working label Jul 4, 2021
@JithinKS97
Copy link
Collaborator

Hey @two-ticks In which branch is this. I can take a look

@two-ticks
Copy link
Owner Author

@JithinKS97 I included them in merge-TeX (added .skip )

https://github.com/two-ticks/p5.teach.js/tree/merge-TeX

it.skip('play should be called', () => {

@two-ticks
Copy link
Owner Author

I tried this and it's working.

it('play should be called', () => {
  const tex = createTeX('2^2');
  const spy = jest.spyOn(tex, 'play').mockImplementation(()=>{});
  tex.play();
  expect(spy).toHaveBeenCalled();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants