-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
38 deletions.
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
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,43 @@ | ||
describe('HELPER sdtd/validate-item-name', () => { | ||
|
||
beforeEach(() => { | ||
sails.helpers.sdtdApi.executeConsoleCommand = sandbox.stub().returns({ | ||
result: ` ammo9mmBulletBall | ||
Listed 1 matching items.` | ||
}); | ||
}) | ||
|
||
it('Validates an item', async () => { | ||
|
||
const trueResult = await sails.helpers.sdtd.validateItemName(sails.testServer.id, "ammo9mmBulletBall"); | ||
|
||
expect(trueResult).to.be.an('boolean'); | ||
expect(trueResult).to.be.true; | ||
|
||
const falseResult = await sails.helpers.sdtd.validateItemName(sails.testServer.id, "some nonexisting item"); | ||
|
||
expect(falseResult).to.be.an('boolean'); | ||
expect(falseResult).to.be.false; | ||
}); | ||
|
||
it('Errors when no server is given', async () => { | ||
await expect(sails.helpers.sdtd.validateItemName(null, "ammo9mmBulletBall")).to.eventually.be.rejectedWith(Error) | ||
}); | ||
|
||
it('Errors when an unexisting server is given', async () => { | ||
const fakeServer = {} | ||
Object.assign(fakeServer, sails.testServer) | ||
|
||
fakeServer.id += 5 | ||
await expect(sails.helpers.sdtd.validateItemName(fakeServer.id, "ammo9mmBulletBall")).to.eventually.be.rejectedWith(Error) | ||
}); | ||
|
||
it('Throws when a request to the server fails', async () => { | ||
sails.helpers.sdtdApi.executeConsoleCommand = sandbox.stub().throws(Error) | ||
await expect(sails.helpers.sdtd.validateItemName(sails.testServer.id, "ammo9mmBulletBall")).to.eventually.be.rejectedWith(Error) | ||
}); | ||
}); | ||
|
||
|
||
|
||
|