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
Fix #115: added test cases for sentiment analysis #207
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9767488
fix 115 added test cases
dbeigi e35f38c
removed space at the end of file
dbeigi 7994614
addressing check failures
dbeigi b783698
Fix #25: Implement basic email sender
66ce98c
Async Function Promise and Env File
074487f
Travis CI Fix
06e3d67
Travis CI
34c4497
Travis CI Fix
4117910
Comments
46e79b2
Implement SMTP
03bef9e
Circle Ci Changes
53ddb71
package.json conflict
58ef00e
info.accepted
3aaad21
git
dbeigi 174fd61
rework on test cases
dbeigi File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
const sentimentAnalysis = require('../src/sentiment-analysis'); | ||
|
||
const expected = { | ||
score: 1, | ||
comparative: 0.1111111111111111, | ||
calculation: [{ allergic: -2 }, { love: 3 }], | ||
tokens: [ | ||
'i', | ||
'love', | ||
'cats', | ||
'but', | ||
'i', | ||
'am', | ||
'allergic', | ||
'to', | ||
'them', | ||
], | ||
words: [ | ||
'allergic', | ||
'love', | ||
], | ||
positive: [ | ||
'love', | ||
], | ||
negative: [ | ||
'allergic', | ||
], | ||
}; | ||
|
||
test('test if sample text does not return the correct object', async () => { | ||
const data = await sentimentAnalysis.run('I like dogs, but my girlfriend is afraid of them'); | ||
expect(data).toEqual(expect.not.objectContaining(expected)); | ||
}); | ||
|
||
test('test if sample text returns the correct object', async () => { | ||
const data = await sentimentAnalysis.run('I love cats, but I am allergic to them.'); | ||
expect(data).toEqual(expect.objectContaining(expected)); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you not just compare
data
toexpected
with a deep equals here? What does.toEqual(expect.not.objectContaining(expected))
mean? Maybe you're right, but this seems odd.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@humphd From what I have read,
.toEqual
should be used for objects. Regards toexpect.not.objectContaining(expected)
, I am using this to check if the contents(properties) of the object do not match what we are expecting. This was suggested by @jatinAroraGit and after reading the docs I agreed to his suggestion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, OK, sounds fine. Thanks for educating me.