2020-01-21 18:12:14 +00:00
|
|
|
// Copyright IBM Corp. 2017,2019. All Rights Reserved.
|
2019-05-08 15:45:37 +00:00
|
|
|
// Node module: loopback-datasource-juggler
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2016-12-31 01:27:49 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const bdd = require('../helpers/bdd-if');
|
|
|
|
const helpers = require('./_helpers');
|
|
|
|
const should = require('should');
|
|
|
|
|
|
|
|
module.exports = function(dataSourceFactory, connectorCapabilities) {
|
2017-01-10 08:18:04 +00:00
|
|
|
const supportsDelete = 'delete' in dataSourceFactory().connector;
|
2016-12-31 01:27:49 +00:00
|
|
|
|
2017-01-10 08:18:04 +00:00
|
|
|
bdd.describeIf(supportsDelete, 'delete', () => {
|
2016-12-31 01:27:49 +00:00
|
|
|
let CacheItem;
|
2017-01-10 08:18:04 +00:00
|
|
|
beforeEach(setupCacheItem);
|
2016-12-31 01:27:49 +00:00
|
|
|
|
2017-01-10 08:18:04 +00:00
|
|
|
it('removes the key-value pair for the given key', () => {
|
2016-12-31 01:27:49 +00:00
|
|
|
return helpers.givenKeys(CacheItem, ['key1', 'key2'])
|
2017-01-06 03:32:41 +00:00
|
|
|
.then(() => CacheItem.delete('key1'))
|
2016-12-31 01:27:49 +00:00
|
|
|
.then(() => CacheItem.keys())
|
2017-01-06 03:32:41 +00:00
|
|
|
.then((keys) => {
|
|
|
|
keys.should.eql(['key2']);
|
2016-12-31 01:27:49 +00:00
|
|
|
});
|
|
|
|
});
|
2017-01-10 08:18:04 +00:00
|
|
|
|
|
|
|
function setupCacheItem() {
|
|
|
|
return helpers.givenCacheItem(dataSourceFactory)
|
|
|
|
.then(ModelCtor => CacheItem = ModelCtor);
|
|
|
|
}
|
2016-12-31 01:27:49 +00:00
|
|
|
});
|
|
|
|
};
|