v3: start to fix unlocking
This commit is contained in:
@@ -43,10 +43,10 @@ describe('shared.ops.unlock', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when user already owns an item', (done) => {
|
||||
it('returns an error when user already owns a full set', (done) => {
|
||||
try {
|
||||
unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('alreadyUnlocked'));
|
||||
@@ -54,6 +54,42 @@ describe('shared.ops.unlock', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when user already owns items in a full set', (done) => {
|
||||
try {
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('alreadyUnlocked'));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('equips an item already owned', () => {
|
||||
expect(user.purchased.background.giant_florals).to.not.exists;
|
||||
|
||||
unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
let afterBalance = user.balance;
|
||||
let response = unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
expect(user.balance).to.equal(afterBalance); // do not bill twice
|
||||
|
||||
expect(response.message).to.not.exists;
|
||||
expect(user.preferences.background).to.equal('giant_florals');
|
||||
});
|
||||
|
||||
it('un-equips an item already equipped', () => {
|
||||
expect(user.purchased.background.giant_florals).to.not.exists;
|
||||
|
||||
unlock(user, {query: {path: backgroundUnlockPath}}); // unlock
|
||||
let afterBalance = user.balance;
|
||||
unlock(user, {query: {path: backgroundUnlockPath}}); // equip
|
||||
let response = unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
expect(user.balance).to.equal(afterBalance); // do not bill twice
|
||||
|
||||
expect(response.message).to.not.exists;
|
||||
expect(user.preferences.background).to.equal('');
|
||||
});
|
||||
|
||||
it('unlocks a full set', () => {
|
||||
let response = unlock(user, {query: {path: unlockPath}});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user