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

Allow Nightmare 3.0+ as a peer dependency #36

Merged
merged 1 commit into from
Mar 25, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"homepage": "https://github.com/Mr0grog/nightmare-real-mouse#readme",
"peerDependencies": {
"nightmare": "^2.10.0"
"nightmare": ">=2.10.0 <4.0"
},
"devDependencies": {
"chai": "^4.0.0",
Expand Down
44 changes: 44 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@ describe('real-mouse', function() {
expect(title).to.equal('Submitted Page');
});
});

it('should reject if the selector is not found', function() {
return nightmare
.goto(`${baseUrl}/simple`)
.realClick('#does-not-exist')
.then(() => {
throw new Error('Using a non-existent selector did not reject');
}, error => {
expect(error.message).to.equal('Cannot find element: "#does-not-exist"');
});
});

it('should reject if the selector was not a string', function() {
return nightmare
.goto(`${baseUrl}/simple`)
.realClick(5)
.then(() => {
throw new Error('Using a non-string selector did not reject');
}, error => {
expect(error.message).to.have.string('"selector" must be a string');
});
});
});

describe('realMouseover', function() {
Expand Down Expand Up @@ -186,6 +208,17 @@ describe('real-mouse', function() {
]);
});
});

it('should reject the nightmare promise if the selector is not found', function() {
return nightmare
.goto(`${baseUrl}/simple`)
.realMouseover('#does-not-exist')
.then(() => {
throw new Error('Using a non-existent selector did not reject');
}, error => {
expect(error.message).to.equal('Cannot find element: "#does-not-exist"');
});
});
});

describe('realMousedown', function() {
Expand Down Expand Up @@ -218,6 +251,17 @@ describe('real-mouse', function() {
]);
});
});

it('should reject the nightmare promise if the selector is not found', function() {
return nightmare
.goto(`${baseUrl}/simple`)
.realMousedown('#does-not-exist')
.then(() => {
throw new Error('Using a non-existent selector did not reject');
}, error => {
expect(error.message).to.equal('Cannot find element: "#does-not-exist"');
});
});
});
});

Expand Down