additional tests and proper handling for purged flag targets, #5232

This commit is contained in:
Julian Lam
2016-12-19 11:16:03 -05:00
parent 7b471b76db
commit ad633aad45
7 changed files with 87 additions and 87 deletions

View File

@@ -82,6 +82,42 @@ describe('Flags', function () {
});
});
describe('.exists()', function () {
it('should return Boolean True if a flag matching the flag hash already exists', function (done) {
Flags.exists('post', 1, 1, function (err, exists) {
assert.ifError(err);
assert.strictEqual(true, exists);
done();
});
});
it('should return Boolean False if a flag matching the flag hash does not already exists', function (done) {
Flags.exists('post', 1, 2, function (err, exists) {
assert.ifError(err);
assert.strictEqual(false, exists);
done();
});
});
});
describe('.targetExists()', function () {
it('should return Boolean True if the targeted element exists', function (done) {
Flags.targetExists('post', 1, function (err, exists) {
assert.ifError(err);
assert.strictEqual(true, exists);
done();
});
});
it('should return Boolean False if the targeted element does not exist', function (done) {
Flags.targetExists('post', 15, function (err, exists) {
assert.ifError(err);
assert.strictEqual(false, exists);
done();
});
});
});
describe('.get()', function () {
it('should retrieve and display a flag\'s data', function (done) {
Flags.get(1, function (err, flagData) {
@@ -252,6 +288,14 @@ describe('Flags', function () {
done();
});
});
it('should return a plain object with no properties if the target no longer exists', function (done) {
Flags.getTarget('user', 15, 1, function (err, data) {
assert.ifError(err);
assert.strictEqual(0, Object.keys(data).length);
done();
});
});
});
describe('.validate()', function () {